<?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: proc http: token authentication in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887488#M350630</link>
    <description>&lt;P&gt;You can try the DEBUG LEVEL=3; statement on PROC HTTP to maybe get more details about what is being sent. Also, since you are using the -k flag on curl, maybe you need this statement in PROC HTTP:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-sas"&gt;&lt;CODE&gt;SSLPARMS "SSLREQCERT"="ALLOW";&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 02 Aug 2023 13:37:31 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2023-08-02T13:37:31Z</dc:date>
    <item>
      <title>proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887451#M350607</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;May I ask someone to help me with following code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let url=xxx;
%let token=_very_long_token_;

filename out temp;
proc http
      url="&amp;amp;url"
      method="GET"
      out=out;
      headers "Authorization" = "Token token = &amp;amp;token" ;
 run;
%put Received code: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;
%put Received phrase: &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It which gives result:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;%put Received code: &amp;amp;SYS_PROCHTTP_STATUS_CODE.;&lt;/P&gt;&lt;P&gt;Received code: 401&lt;/P&gt;&lt;P&gt;%put Received phrase: &amp;amp;SYS_PROCHTTP_STATUS_PHRASE.;&lt;/P&gt;&lt;P&gt;Received phrase: Unauthorized&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When the same is done in bash, it works correctly:&lt;/P&gt;&lt;PRE&gt;url=xxx;&lt;BR /&gt;token=_very_long_token_;&lt;BR /&gt;&lt;BR /&gt;curl -k -H "Authorization: Token token=\"$token\"" "$url"&lt;/PRE&gt;&lt;P&gt;Why the SAS code does not work identically to the bash?&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 09:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887451#M350607</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-08-02T09:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887482#M350626</link>
      <description>&lt;P&gt;Are you certain the form is "Authorization: Token token &amp;lt;&lt;EM&gt;token-value&lt;/EM&gt;&amp;gt;" ?&amp;nbsp; And not just "Authorization: Token &amp;lt;&lt;EM&gt;token-value&lt;/EM&gt;&amp;gt;" ?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've seen a lot of APIs and token schemes, but using the&amp;nbsp;&lt;STRONG&gt;token&lt;/STRONG&gt; keyword twice and then the actual token seems odd.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 12:47:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887482#M350626</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-08-02T12:47:38Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887484#M350627</link>
      <description>&lt;P&gt;Oh, also your bash script puts the&amp;nbsp;&lt;EM&gt;token&lt;/EM&gt; value in quotes, but your SAS code does not have that.&amp;nbsp; Maybe you need something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt; headers "Authorization" = "Token token = ""&amp;amp;token""" ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 12:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887484#M350627</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-08-02T12:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887485#M350628</link>
      <description>&lt;P&gt;Chris, thank you for the suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;"Token token = ": I'm not completely sure about it, but since it works in bash, it should be correct.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Quotes: Yes, I know about this difference, but I've already tried your suggestion, as well as (one by one and a few other modifications how to pass the quotes):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let token=%22&amp;amp;token%22;
%let token=%str(%")&amp;amp;token%str(%");
%let token=%bquote(")&amp;amp;token%bquote(");&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Nothing works. Sorry, I should have mentioned that in my original post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 13:03:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887485#M350628</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-08-02T13:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887488#M350630</link>
      <description>&lt;P&gt;You can try the DEBUG LEVEL=3; statement on PROC HTTP to maybe get more details about what is being sent. Also, since you are using the -k flag on curl, maybe you need this statement in PROC HTTP:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-sas"&gt;&lt;CODE&gt;SSLPARMS "SSLREQCERT"="ALLOW";&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Aug 2023 13:37:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887488#M350630</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-08-02T13:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887501#M350635</link>
      <description>&lt;P&gt;Do you suggest&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc http
      url="&amp;amp;url"
      method="GET"
      out=out;
      headers "Authorization" = "Token token = ""&amp;amp;token""" ;&lt;BR /&gt;      SSLPARMS "SSLREQCERT"="ALLOW";&lt;BR /&gt;      &lt;SPAN&gt;DEBUG LEVEL=3;&lt;/SPAN&gt;
 run;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If my syntax is correct (I haven't found an example of the SSLPARMS usage), it makes no difference. The debug level of 3 procudes:&lt;/P&gt;&lt;PRE&gt;&amp;gt; GET /XXX/YYY/ZZZ HTTP/1.1
&amp;gt; User-Agent: SAS/9
&amp;gt; Host: XXX
&amp;gt; Accept: */*
&amp;gt; Connection: Keep-Alive
&amp;gt; Authorization: ************
&amp;gt;
&amp;lt; HTTP/1.1 401 Unauthorized
&amp;lt; server: nginx
&amp;lt; date: Wed, 02 Aug 2023 14:41:52 GMT
&amp;lt; content-type: text/plain
&amp;lt; content-length: 21
&amp;lt; cache-control: no-cache
&amp;lt; x-request-id: ea3c2385-fcf4-4a21-9df0-69ade9a4b6c7
&amp;lt; x-runtime: 0.000492
&amp;lt; 
&amp;lt; 00007F765802B461: 41 75 74 68 6F 72 69 7A 61 74 69 6F 6E 20 6D 69 Authorization mi
&amp;lt; 00007F765802B471: 73 73 69 6E 67                                  ssing           
NOTE: PROCEDURE HTTP used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      
Received code: 401
Received phrase: Unauthorized&lt;/PRE&gt;&lt;P&gt;Url and the host are correct and identical to the bash, I just don't want to share it unless really necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also tried various options of quoting the token, no success.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 14:47:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887501#M350635</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-08-02T14:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887504#M350638</link>
      <description>&lt;P&gt;Is it a documented API that we can see somewhere? Or something that's internal/proprietary. Sometimes by looking at API doc I can work out the magic incantation.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 14:59:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887504#M350638</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-08-02T14:59:50Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887510#M350641</link>
      <description>&lt;P&gt;Ok, if you are willing to dig into the topic, I'm trying to use conjure api with the token:&amp;nbsp;&lt;A href="https://docs.conjur.org/Latest/en/Content/Developer/Conjur_API_Authenticate.htm?tocpath=Developer%7CREST%C2%A0APIs%7C_____3" target="_blank" rel="noopener"&gt;https://docs.conjur.org/Latest/en/Content/Developer/Conjur_API_Authenticate.htm?tocpath=Developer%7CREST%C2%A0APIs%7C_____3&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's equivalent of the last example&amp;nbsp;without the certificate (it works without it in bash, see my original post).&lt;/P&gt;&lt;PRE&gt;curl --cacert &amp;lt;certfile&amp;gt; \
     -H "Authorization: Token token=\"$response\"" \
     &amp;lt;url&amp;gt;&lt;/PRE&gt;&lt;P&gt;I haven't found any example for the conjure API with SAS.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The token has been previously obtained by another&amp;nbsp;&lt;EM&gt;proc http&lt;/EM&gt; and coded to base64. This should be correct, because when I copy-paste the token obtained in SAS to the shell script, it also works (when not using a "hard-copy" of the token, the bash script downloads the token itself as well).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a limited time validity of the token; but, of course, I'm sure that all the time I'm using a valid one, which was downloaded right before this&amp;nbsp;&lt;EM&gt;proc http.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: This may be slightly more appropriate:&amp;nbsp;&lt;A href="https://docs.conjur.org/Latest/en/Content/Developer/Conjur_API_Retrieve_Secret.htm?tocpath=Developer%7CREST%C2%A0APIs%7C_____8" target="_blank"&gt;https://docs.conjur.org/Latest/en/Content/Developer/Conjur_API_Retrieve_Secret.htm?tocpath=Developer%7CREST%C2%A0APIs%7C_____8&lt;/A&gt;&amp;nbsp;(obtaining a password, the authentication is used as shown above)&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 15:25:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/887510#M350641</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-08-02T15:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/888523#M351042</link>
      <description>Solved by adding the certificate. However, it remains mysterious to me, because bash ("curl -k") doesn't use any, while SAS needs it.</description>
      <pubDate>Wed, 09 Aug 2023 09:04:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/888523#M351042</guid>
      <dc:creator>asasgdsfa</dc:creator>
      <dc:date>2023-08-09T09:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: proc http: token authentication</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/888552#M351051</link>
      <description>&lt;P&gt;It may be that your curl/bash environment was finding the cert via normal environment variables that were not available in your SAS session.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 12:38:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-http-token-authentication/m-p/888552#M351051</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-08-09T12:38:25Z</dc:date>
    </item>
  </channel>
</rss>

