<?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 Re: Passing user password to REST authentication in SAS in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682626#M925</link>
    <description>&lt;P&gt;I'll check on the ';' separation question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is a quick connection test/API call I run to verify connectivity from SASStudioV. I do not use the semi-colon separator in this call :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http method='GET'
url="https://mysasserver.sas.com/identities/users?limit=10000"
oauth_bearer=SAS_SERVICES
out=out;
run;

%put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This returns a http 200 code and the contents of the GET users call.&amp;nbsp; Here is the beginning of the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;No items
1    %studio_hide_wrapper;
82   filename out TEMP;
83   proc http method='GET'
84   url="https://mysasserver.sas.com/identities/users?limit=10000"
85   oauth_bearer=SAS_SERVICES
86   out=out;
87   run;
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.16 seconds
      cpu time            0.04 seconds
      
88   
89   %put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;
return code is: 200
90   
91   data _null_;
92   infile out;
93   input;
94   put _infile_;
95   run;
NOTE: The infile OUT is:
      Filename=/sastmp/saswork/SAS_work952E000033AC_my-sas/#LN00140,
      Owner Name=jofurb,Group Name=unix_marketing,
      Access Permission=-rw-r--r--,
      Last Modified=09Sep2020:09:12:18,
      File Size (bytes)=43123
&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;&amp;lt;collection accept="application/vnd.sas.identity.user.summary" count="41" lim
it="10000" name="users" start="0" version="2"&amp;gt;&amp;lt;items&amp;gt;&amp;lt;userSummary version="1"&amp;gt;&amp;lt;links&amp;gt;&amp;lt;link href="/identities/users/brumil" method="G
ET" rel="self" type="application/vnd.sas.identity.user".........."
NOTE: 1 record was read from the infile OUT.
      The minimum record length was 32767.
      The maximum record length was 32767.
      One or more lines were truncated.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
96   
97   %studio_hide_wrapper;
108  
109  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Sep 2020 13:22:27 GMT</pubDate>
    <dc:creator>joeFurbee</dc:creator>
    <dc:date>2020-09-09T13:22:27Z</dc:date>
    <item>
      <title>Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/681980#M915</link>
      <description>&lt;P&gt;I have translate our Viya API code from a python POC to SAS. I am using proc http to do the REST calls. In the first authenication, I used a user prompt to get the password in python. I was going to implement something using getPass to retrieve the user password in python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using &amp;amp;sysuserid to get the logon id, but is there anyway to get the password from the session, akin to getPass? Or retrieving it from a user prompt? I do want to avoid hardcoding the password for obvious reasons. I need the password and username to authenticate and&amp;nbsp;obtain the access_token.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 09:03:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/681980#M915</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2020-09-07T09:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682002#M916</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68234"&gt;@Ullsokk&lt;/a&gt;&amp;nbsp;- you don't need to prompt for credentials when calling from within SAS, at least not from within SASStudioV, as you are already authenticated.&amp;nbsp; You can just use the "&lt;SPAN&gt;oauth_bearer=sas_services" proc http option.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you'd like to use Token authentication, and you have the requisite admin rights, you can create using this macro:&amp;nbsp;&amp;nbsp;&lt;A href="https://github.com/sasjs/core/blob/main/viya/mv_registerclient.sas" target="_blank"&gt;https://github.com/sasjs/core/blob/main/viya/mv_registerclient.sas&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you do this a lot you can even use this web app:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;&lt;A href="https://sasjs.io/apps/#viya-client-token-generator" target="_blank"&gt;https://sasjs.io/apps/#viya-client-token-generator&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For lots of examples of using proc http with the SAS APIs in Viya, feel free to explore:&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/sasjs/core/tree/main/viya" target="_blank"&gt;https://github.com/sasjs/core/tree/main/viya&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Sep 2020 11:52:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682002#M916</guid>
      <dc:creator>AllanBowe</dc:creator>
      <dc:date>2020-09-07T11:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682241#M921</link>
      <description>&lt;P&gt;I can't get the option to work. Tried placing it everywhere, both in sas studio 9.4, E.G. 9.4 and sas studio V on Viya. I assume the data\in is not used when using this method?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* did not use this: %let str ="grant_type=password%str(&amp;amp;)username=&amp;amp;sysuserid.%str(&amp;amp;)password=&amp;amp;password.";

proc http url="https://aiu-viya-server.com/SASLogon/oauth/token" 
method="POST" 
Webusername="MyApp"
webpassword="password"
/*in=&amp;amp;str.*/
headerout=hdrs
headerout_overwrite
out=out
;

headers "Accept"="application/json";
OAUTH_BEARER=SAS_SERVICES;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Where is the OAUTH_BEARER supposed to go? And is the in\data suppose to be missing? Or contain something like&amp;nbsp;&amp;nbsp;&lt;CODE class=" language-sas"&gt;grant_type=password%str(&amp;amp;)username=&amp;amp;somemacrovalue.%str(&amp;amp;)password=&amp;amp;anothermacrovalue.&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;In any case, the application code will not be running in a Viya\ SAS studio V environment, but as a sas code deployed through DI studio.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it seems like a better approach, if I understand this correctly, is to use a refresh token (no username and password), and to enter the refresh token in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I basically have to change the way of obtaining an access token to passing a refresh token. Will look into the link you provided.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2020 13:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682241#M921</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2020-09-08T13:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682471#M923</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/68234"&gt;@Ullsokk&lt;/a&gt;,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you have a syntax error in your proc http code. Here is an example of using oauth_bearer with proc http:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let BASE_URI=%sysfunc(getoption(servicesbaseurl));
* FILEREFs for the response and the response headers;
filename resp temp;
filename resp_hdr temp;

proc http url="&amp;amp;BASE_URI/jobDefinitions/definitions/?limit=50"
method='get'
oauth_bearer=sas_services
out=resp
headerout=resp_hdr
headerout_overwrite;
run; quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;as &lt;A href="https://go.documentation.sas.com/?docsetId=jobexecug&amp;amp;docsetTarget=n0qo7wn74c7mxjn0z46prg7xtakd.htm&amp;amp;docsetVersion=2.2&amp;amp;locale=en#n1b7b1t04ogkv1n1jo0oi7z1k88k" target="_self"&gt;found in the documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 01:55:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682471#M923</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2020-09-09T01:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682522#M924</link>
      <description>&lt;P&gt;I was using this as a guide:&lt;A href="https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3232-2019.pdf" target="_blank"&gt;https://www.sas.com/content/dam/SAS/support/en/sas-global-forum-proceedings/2019/3232-2019.pdf&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Which seems to have a syntax error, stating that the auth is supposed to be separated by a semicolon:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc http url="http:\\viya-webservice.mydomain.com";&lt;BR /&gt;OAUTH_BEARER=SAS_SERVICES;&lt;BR /&gt;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Tried again with the auth_bearer inside the first semicolon. In both viya sas studio V and EG 8.2 on sas 9.4, I get a 401 unautherized error. The syntax does not seem to be regonized, but I get no error message apart from the response file beeing missing when I try to read it.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 06:36:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682522#M924</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2020-09-09T06:36:30Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682626#M925</link>
      <description>&lt;P&gt;I'll check on the ';' separation question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is a quick connection test/API call I run to verify connectivity from SASStudioV. I do not use the semi-colon separator in this call :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
proc http method='GET'
url="https://mysasserver.sas.com/identities/users?limit=10000"
oauth_bearer=SAS_SERVICES
out=out;
run;

%put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;

data _null_;
infile out;
input;
put _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This returns a http 200 code and the contents of the GET users call.&amp;nbsp; Here is the beginning of the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;No items
1    %studio_hide_wrapper;
82   filename out TEMP;
83   proc http method='GET'
84   url="https://mysasserver.sas.com/identities/users?limit=10000"
85   oauth_bearer=SAS_SERVICES
86   out=out;
87   run;
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.16 seconds
      cpu time            0.04 seconds
      
88   
89   %put return code is: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;
return code is: 200
90   
91   data _null_;
92   infile out;
93   input;
94   put _infile_;
95   run;
NOTE: The infile OUT is:
      Filename=/sastmp/saswork/SAS_work952E000033AC_my-sas/#LN00140,
      Owner Name=jofurb,Group Name=unix_marketing,
      Access Permission=-rw-r--r--,
      Last Modified=09Sep2020:09:12:18,
      File Size (bytes)=43123
&amp;lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&amp;gt;&amp;lt;collection accept="application/vnd.sas.identity.user.summary" count="41" lim
it="10000" name="users" start="0" version="2"&amp;gt;&amp;lt;items&amp;gt;&amp;lt;userSummary version="1"&amp;gt;&amp;lt;links&amp;gt;&amp;lt;link href="/identities/users/brumil" method="G
ET" rel="self" type="application/vnd.sas.identity.user".........."
NOTE: 1 record was read from the infile OUT.
      The minimum record length was 32767.
      The maximum record length was 32767.
      One or more lines were truncated.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
96   
97   %studio_hide_wrapper;
108  
109  &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Sep 2020 13:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682626#M925</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2020-09-09T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Passing user password to REST authentication in SAS</title>
      <link>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682827#M926</link>
      <description>&lt;P&gt;Can confirm that this worked for med with the correctly placed semi colon, but only in SAS studio V in Viya. The appilcation code however will be triggered as a DI stuidio generated sascode running in a 9.4. environment, so I guess one sollution is to create a new user just for application authentication, or getting the approach without password authentication to work (using a refresh token if I understand correctly)&lt;/P&gt;</description>
      <pubDate>Thu, 10 Sep 2020 06:39:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Passing-user-password-to-REST-authentication-in-SAS/m-p/682827#M926</guid>
      <dc:creator>Ullsokk</dc:creator>
      <dc:date>2020-09-10T06:39:28Z</dc:date>
    </item>
  </channel>
</rss>

