<?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: Translating cURL command to equivalent PROC HTTP statement? in Developers</title>
    <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/617656#M621</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274763"&gt;@RichardP&lt;/a&gt;. I'm not sure where you'll be using the proc http call, but basic auth is not considered best practice from a security standpoint. To answer you question the following call worked for me (I substituted your env values in the example):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
filename hdrs TEMP;
proc http url="http://sasviya01.race.sas.com/SASLogon/oauth/token" 
method="POST" 
auth_basic
Webusername="sas.cli"
webpassword=""
in='grant_type=password&amp;amp;username=geladm&amp;amp;password=lnxsas'
headerout=hdrs
headerout_overwrite
out=out;
headers "Accept"="application/json";
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;I ran the program in SAS Studio. The first part of the program retrieves the access token. The second part displays the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The -u in your original cURL call is for "client_id:client_secret". This is reflected in the proc http call above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps,&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Blog post articles on authentication you may find helpful:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2020/07/30/curl-to-proc-http/" target="_self"&gt;How to translate your cURL command to PROC HTTP&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2019/01/25/authentication-to-sas-viya/" target="_self"&gt;Authentication to SAS Viya: a couple of approaches&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2018/01/16/sas-viya-3-3-authentication-options/" target="_self"&gt;SAS Viya 3.3 authentication options&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/01/16/hide-rest-api-tokens/" target="_self"&gt;How to secure your REST API credentials in SAS programs&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
    <pubDate>Mon, 17 Aug 2020 18:18:15 GMT</pubDate>
    <dc:creator>joeFurbee</dc:creator>
    <dc:date>2020-08-17T18:18:15Z</dc:date>
    <item>
      <title>Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616249#M614</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can someone please help me convert the following (working) cURL command into the PROC HTTP equivalent?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -k &lt;A href="http://sasviya01.race.sas.com/SASLogon/oauth/token" target="_blank"&gt;http://sasviya01.race.sas.com/SASLogon/oauth/token&lt;/A&gt; &amp;nbsp;-H "Content-Type: application/x-www-form-urlencoded" -u "sas.cli:" -d "grant_type=password&amp;amp;username=geladm&amp;amp;password=lnxsas"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This is as far as I have got, however I am struggling to understand the -u switch "sas.cli:"&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;proc http url="&lt;A href="http://sasviya01.race.sas.com/SASLogon/oauth/token" target="_blank"&gt;http://sasviya01.race.sas.com/SASLogon/oauth/token&lt;/A&gt;" method="GET" auth_ntlm&lt;/DIV&gt;&lt;DIV&gt;in="grant_type=password&amp;amp;username=geladm&amp;amp;password=lnxsas"&lt;/DIV&gt;&lt;DIV&gt;out=response&lt;/DIV&gt;&lt;DIV&gt;headerout=hdrout&lt;/DIV&gt;&lt;DIV&gt;headerout_overwrite;&lt;/DIV&gt;&lt;DIV&gt;headers "Accept"="application/json";&lt;/DIV&gt;&lt;DIV&gt;run;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;any help much appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;regards,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Richard&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 16:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616249#M614</guid>
      <dc:creator>RichardP</dc:creator>
      <dc:date>2020-01-09T16:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616262#M615</link>
      <description>&lt;P&gt;-u in cURL refers to user name/password for basic authentication. In the below, "sas.cli" would be the username and whatever is after the ":" would be the password.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In PROC HTTP you are using AUTH_NTLM instead of basic authentication.&amp;nbsp; You would instead want to use AUTH_BASIC and WEB_USERNAME and WEB_PASSWORD options.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 16:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616262#M615</guid>
      <dc:creator>FriedEgg</dc:creator>
      <dc:date>2020-01-09T16:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616933#M618</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi thanks for your reply. In my cURL command I have a username "geladm" and a password "lnxsas". Therefore I am confused as to where the -u switch information should go. I have tried your suggestion and a whole heap of combinations but I always get an access error.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 14:41:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/616933#M618</guid>
      <dc:creator>RichardP</dc:creator>
      <dc:date>2020-01-13T14:41:31Z</dc:date>
    </item>
    <item>
      <title>Re: Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/617656#M621</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/274763"&gt;@RichardP&lt;/a&gt;. I'm not sure where you'll be using the proc http call, but basic auth is not considered best practice from a security standpoint. To answer you question the following call worked for me (I substituted your env values in the example):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename out TEMP;
filename hdrs TEMP;
proc http url="http://sasviya01.race.sas.com/SASLogon/oauth/token" 
method="POST" 
auth_basic
Webusername="sas.cli"
webpassword=""
in='grant_type=password&amp;amp;username=geladm&amp;amp;password=lnxsas'
headerout=hdrs
headerout_overwrite
out=out;
headers "Accept"="application/json";
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;I ran the program in SAS Studio. The first part of the program retrieves the access token. The second part displays the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The -u in your original cURL call is for "client_id:client_secret". This is reflected in the proc http call above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps,&lt;/P&gt;
&lt;P&gt;Joe&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;U&gt;Blog post articles on authentication you may find helpful:&lt;/U&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2020/07/30/curl-to-proc-http/" target="_self"&gt;How to translate your cURL command to PROC HTTP&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2019/01/25/authentication-to-sas-viya/" target="_self"&gt;Authentication to SAS Viya: a couple of approaches&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sgf/2018/01/16/sas-viya-3-3-authentication-options/" target="_self"&gt;SAS Viya 3.3 authentication options&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2018/01/16/hide-rest-api-tokens/" target="_self"&gt;How to secure your REST API credentials in SAS programs&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 17 Aug 2020 18:18:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/617656#M621</guid>
      <dc:creator>joeFurbee</dc:creator>
      <dc:date>2020-08-17T18:18:15Z</dc:date>
    </item>
    <item>
      <title>Re: Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/618043#M629</link>
      <description>&lt;P&gt;Joe,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you so much for this!! Your solution worked first time. In response to your remark, I will be creating a simple report showing the tables used in a VA report. I actually posted a question about this (and thank you for your help here as well).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Developers/Create-a-report-table-relationship-report/m-p/617481" target="_blank"&gt;https://communities.sas.com/t5/Developers/Create-a-report-table-relationship-report/m-p/617481&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was following a paper -&amp;nbsp;OpenID Connect Opens the Door to SAS® Viya® APIs. I was trying to create an access token for SAS Studio (duh!) Thanks to your help I now realise that SAS Studio is already a client and therefore gaining an access token is not needed. By adding the OAUTH_BEARER=SAS_SERVICES to the PROC HTTP statement I can take advantage of the authentication which took place with SAS Logon.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;many thanks!&lt;/P&gt;&lt;P&gt;Richard&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jan 2020 10:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/618043#M629</guid>
      <dc:creator>RichardP</dc:creator>
      <dc:date>2020-01-17T10:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Translating cURL command to equivalent PROC HTTP statement?</title>
      <link>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/621485#M646</link>
      <description>&lt;P&gt;Very helpful.&amp;nbsp; BTW, you may find it a bit easier to display the response JSON to the log using the &lt;A href="https://go.documentation.sas.com/?docsetId=lestmtsglobal&amp;amp;docsetTarget=n1jfdetszx99ban1rl4zll6tej7j.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en#p1ptq5h1u7ehyzn1ablj0fxl1me2" target="_self"&gt;jsonpp() function&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;data _null_; &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; rc = jsonpp('out','log');&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt; run;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 16:43:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/Translating-cURL-command-to-equivalent-PROC-HTTP-statement/m-p/621485#M646</guid>
      <dc:creator>carl_sommer</dc:creator>
      <dc:date>2020-01-31T16:43:12Z</dc:date>
    </item>
  </channel>
</rss>

