<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic OAth via a proc http call in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935604#M45014</link>
    <description>&lt;P&gt;I would like to pass the scope as parameter but up to now it failed. Please note that the credential.sas file contains :&amp;nbsp;&lt;CODE class=" language-sas"&gt;client_id,client_secret, scope&amp;nbsp;as&amp;nbsp;global&amp;nbsp;macro&amp;nbsp;variable.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I want to replace this statement which works&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;in='grant_type=client_credentials&amp;amp;scope=manage:all'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;for&amp;nbsp;in='grant_type=client_credentials&amp;amp;scope= &amp;amp;scope.'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;But the above line those not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/finsys/.../TEST/Credentials.sas


%macro BearerToken(client_id, client_secret,scope);

/* Example of call: %BearerToken(&amp;amp;client_id., &amp;amp;client_secret.); */


/* For debugging only ! Reading the input values 
%put reading the input values: &amp;amp;=client_id &amp;amp;=client_secret;
*/

/**** Converting the Client_id and the client_secret using base64 encoder to obtain the corresponding Basic Authentication value  ***/
data _null_;
  length newString $200.;
  newString=cats("&amp;amp;client_id.",":","&amp;amp;client_secret.");
  call symputx('Basic_Auth',put(trim(newString),$base64x300.),'g');
run;

/* For debugging only !
%put &amp;amp;=Basic_Auth;
*/


/* Sending the Basic Authentication value to the appropriate web site, via an API call to obtain the Bearer_token ****/

options set=SSLREQCERT="allow";
filename resp temp;

/* must include content-type/CT= option */
proc http 
 url="https://ca1.qualtrics.com/oauth2/token"
 method='POST'
 AUTH_BASIC
 AUTH_NEGOTIATE
 ct="application/x-www-form-urlencoded"
/* in='grant_type=client_credentials&amp;amp;scope=read:survey_responses read:users'*/
/*in='grant_type=client_credentials&amp;amp;scope=manage:all'*/
 in=%str(') grant_type=client_credentials&amp;amp;scope= &amp;amp;scope %str(')
 out=resp;
 headers "Authorization" = "Basic &amp;amp;Basic_Auth."; 
;
run;
/* Checking the log for the API Call */

%put &amp;amp;=SYS_PROCHTTP_STATUS_CODE;
data _null_;
 rc=jsonpp('resp','log');
run;

/* Getting the Bearer Token */

libname auth json fileref=resp;
%global Bearertimer_start BTExpIn; 
data BearerInfo;
 set auth.root;
 %let Bearertimer_start = %sysfunc(datetime());
 call symputx('BearerToken',access_token,'g');
 call symput('BTExpIn',expires_in);
 call symputx('BearerTokenValid','Yes','g');
run;
%put &amp;amp;=BearerToken. &amp;amp;=BTExpIn. &amp;amp;=Bearertimer_start.;
%mend BearerToken;
% BearerToken(&amp;amp;client_id, &amp;amp;client_secret, &amp;amp;scope);&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 Jul 2024 14:33:20 GMT</pubDate>
    <dc:creator>alepage</dc:creator>
    <dc:date>2024-07-12T14:33:20Z</dc:date>
    <item>
      <title>OAth via a proc http call</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935604#M45014</link>
      <description>&lt;P&gt;I would like to pass the scope as parameter but up to now it failed. Please note that the credential.sas file contains :&amp;nbsp;&lt;CODE class=" language-sas"&gt;client_id,client_secret, scope&amp;nbsp;as&amp;nbsp;global&amp;nbsp;macro&amp;nbsp;variable.&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;I want to replace this statement which works&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;in='grant_type=client_credentials&amp;amp;scope=manage:all'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-sas"&gt;for&amp;nbsp;in='grant_type=client_credentials&amp;amp;scope= &amp;amp;scope.'&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;But the above line those not work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/finsys/.../TEST/Credentials.sas


%macro BearerToken(client_id, client_secret,scope);

/* Example of call: %BearerToken(&amp;amp;client_id., &amp;amp;client_secret.); */


/* For debugging only ! Reading the input values 
%put reading the input values: &amp;amp;=client_id &amp;amp;=client_secret;
*/

/**** Converting the Client_id and the client_secret using base64 encoder to obtain the corresponding Basic Authentication value  ***/
data _null_;
  length newString $200.;
  newString=cats("&amp;amp;client_id.",":","&amp;amp;client_secret.");
  call symputx('Basic_Auth',put(trim(newString),$base64x300.),'g');
run;

/* For debugging only !
%put &amp;amp;=Basic_Auth;
*/


/* Sending the Basic Authentication value to the appropriate web site, via an API call to obtain the Bearer_token ****/

options set=SSLREQCERT="allow";
filename resp temp;

/* must include content-type/CT= option */
proc http 
 url="https://ca1.qualtrics.com/oauth2/token"
 method='POST'
 AUTH_BASIC
 AUTH_NEGOTIATE
 ct="application/x-www-form-urlencoded"
/* in='grant_type=client_credentials&amp;amp;scope=read:survey_responses read:users'*/
/*in='grant_type=client_credentials&amp;amp;scope=manage:all'*/
 in=%str(') grant_type=client_credentials&amp;amp;scope= &amp;amp;scope %str(')
 out=resp;
 headers "Authorization" = "Basic &amp;amp;Basic_Auth."; 
;
run;
/* Checking the log for the API Call */

%put &amp;amp;=SYS_PROCHTTP_STATUS_CODE;
data _null_;
 rc=jsonpp('resp','log');
run;

/* Getting the Bearer Token */

libname auth json fileref=resp;
%global Bearertimer_start BTExpIn; 
data BearerInfo;
 set auth.root;
 %let Bearertimer_start = %sysfunc(datetime());
 call symputx('BearerToken',access_token,'g');
 call symput('BTExpIn',expires_in);
 call symputx('BearerTokenValid','Yes','g');
run;
%put &amp;amp;=BearerToken. &amp;amp;=BTExpIn. &amp;amp;=Bearertimer_start.;
%mend BearerToken;
% BearerToken(&amp;amp;client_id, &amp;amp;client_secret, &amp;amp;scope);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 Jul 2024 14:33:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935604#M45014</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-07-12T14:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: OAth via a proc http call</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935614#M45015</link>
      <description>&lt;P&gt;If you want the &amp;amp;scope macro variable to be resolved, the IN= value must be in double quotes. Using single quotes will prevent the macro processor from resolving the value.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 14:40:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935614#M45015</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-07-12T14:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: OAth via a proc http call</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935619#M45016</link>
      <description>&lt;P&gt;could you please provide an example&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/*in='grant_type=client_credentials&amp;amp;scope=manage:all'*/&lt;BR /&gt;/*in="grant_type=client_credentials&amp;amp;scope=&amp;amp;scope"*/&lt;BR /&gt;in="grant_type=client_credentials&amp;amp;scope=manage:all"&lt;/P&gt;
&lt;P&gt;The only one that is working is :&lt;/P&gt;
&lt;P&gt;in='grant_type=client_credentials&amp;amp;scope=manage:all'&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%let scope=manage:all;&lt;/P&gt;
&lt;P&gt;So I need to find a way to reproduce this string:&amp;nbsp;'grant_type=client_credentials&amp;amp;scope=manage:all'&lt;/P&gt;
&lt;P&gt;by passing &amp;amp;scope and remember that the first &amp;amp;scope should not be interpreted as a macro variable . How to do that ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 15:31:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935619#M45016</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2024-07-12T15:31:23Z</dc:date>
    </item>
    <item>
      <title>Re: OAth via a proc http call</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935620#M45017</link>
      <description>&lt;P&gt;Try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let scope = manage:all;

in="grant_type=client_credentials%str(&amp;amp;)scope=&amp;amp;scope."&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 12 Jul 2024 15:35:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/OAth-via-a-proc-http-call/m-p/935620#M45017</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2024-07-12T15:35:14Z</dc:date>
    </item>
  </channel>
</rss>

