<?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: Cannot get Proc HTTP to return Access Token via REST API... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492667#M129503</link>
    <description>&lt;P&gt;Great! You can also use DATA step to write body content to a SAS fileref, then specify the fileref on the&amp;nbsp;&lt;STRONG&gt;in=&lt;/STRONG&gt; option in PROC HTTP.&amp;nbsp; Useful when the body content is more data driven.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Sep 2018 14:14:54 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2018-09-05T14:14:54Z</dc:date>
    <item>
      <title>Cannot get Proc HTTP to return Access Token via REST API...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492629#M129486</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am struggling to get Proc HTTP to return an Access Token from a company called Listrak, uing their REST API. I AM able to get it from Postman, using their instructions, but I cannot seem to translate that into something that works with Proc HTTP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the Postman HTTP code that works(client_id/secret x'd out for security)...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;POST /OAuth2/Token HTTP/1.1&lt;BR /&gt;Host: auth.listrak.com&lt;BR /&gt;Cache-Control: no-cache&lt;BR /&gt;Postman-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&lt;BR /&gt;Content-Type: application/x-www-form-urlencoded&lt;BR /&gt;&lt;BR /&gt;grant_type=client_credentials&amp;amp;client_id=xxxxxxxxxxxxxxxxxxxxxxxx&amp;amp;client_secret=xxxxxxxxxxxxxxxxxxxxx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The SAS code I have tried is this but it always returns a "Bad Request" from the headerout and&amp;nbsp;{"error":"Invalid Grant Type"} error from the resptkn file...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename resptkn TEMP;&lt;BR /&gt;filename headers TEMP;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let client_credentials = xxxxxxxxxxxxxxxxxxxxxx;&lt;/P&gt;&lt;P&gt;%let client secret = xxxxxxxxxxxxxxxxxxxxxxxxxx;&lt;/P&gt;&lt;P&gt;%let oauth2_token = &lt;A href="https://auth.listrak.com/OAuth2/Token" target="_blank"&gt;https://auth.listrak.com/OAuth2/Token&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc http&lt;BR /&gt;&amp;nbsp; method="POST"&lt;BR /&gt;&amp;nbsp; url="&amp;amp;oauth2_token.?grant_type=client_credentials%str(&amp;amp;)client_id=&amp;amp;client_id%str(&amp;amp;)client_secret=&amp;amp;client_secret"&lt;BR /&gt;&amp;nbsp; ct="application/x-www-form-urlencoded"&lt;BR /&gt;&amp;nbsp; headerout=headers&lt;BR /&gt;&amp;nbsp; out=resptkn&lt;BR /&gt;&amp;nbsp; HEADEROUT_OVERWRITE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I "think" the issue is based on the fact that with Postman, I had to put the credentials and grant type in the BODY portion and not the header portion. While I know about the Headers option in Proc HTTP, I don't know how to put anything into a BODY portiong with proc HTTP.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Once I have a token, I am able to connect to their REST&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 12:57:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492629#M129486</guid>
      <dc:creator>Chuck_IV4</dc:creator>
      <dc:date>2018-09-05T12:57:38Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get Proc HTTP to return Access Token via REST API...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492663#M129502</link>
      <description>&lt;P&gt;I FINALLY got it. WOW. Here is the code I used to get it to generate the code...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc http&lt;BR /&gt;&amp;nbsp; method="POST"&lt;BR /&gt;&amp;nbsp; url="&lt;A href="https://auth.listrak.com/OAuth2/Token" target="_blank"&gt;https://auth.listrak.com/OAuth2/Token&lt;/A&gt;"&lt;BR /&gt;&amp;nbsp; ct="application/x-www-form-urlencoded"&lt;BR /&gt;&amp;nbsp; in='grant_type=client_credentials&amp;amp;client_id=xxxxxxxxxxxxxxxx&amp;amp;client_secret=xxxxxxxxxxxxxxxxx'&lt;BR /&gt;&amp;nbsp; headerout=headers&lt;BR /&gt;&amp;nbsp; out=resptkn&lt;BR /&gt;&amp;nbsp; HEADEROUT_OVERWRITE;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I guess the key was to not only send the grant type via the IN= option, but also the credentials. That seemed to be my hangup. I kept trying to send them as part of the initial URL.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 13:52:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492663#M129502</guid>
      <dc:creator>Chuck_IV4</dc:creator>
      <dc:date>2018-09-05T13:52:15Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get Proc HTTP to return Access Token via REST API...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492667#M129503</link>
      <description>&lt;P&gt;Great! You can also use DATA step to write body content to a SAS fileref, then specify the fileref on the&amp;nbsp;&lt;STRONG&gt;in=&lt;/STRONG&gt; option in PROC HTTP.&amp;nbsp; Useful when the body content is more data driven.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Sep 2018 14:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/492667#M129503</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2018-09-05T14:14:54Z</dc:date>
    </item>
    <item>
      <title>Re: Cannot get Proc HTTP to return Access Token via REST API...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/625305#M184296</link>
      <description>&lt;P&gt;Hi Guys.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all informations, i really appreciate it.&lt;/P&gt;&lt;P&gt;Indeed, i am in the same position.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to connect with a proc http to&amp;nbsp;return Access Token via REST API...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Potstman, i get the acess token without problem :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Method : POST&lt;/P&gt;&lt;P&gt;URL : "&lt;SPAN&gt;https://services-xxxxxxxxxxxxxx/token"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Passing information in the body :&amp;nbsp;&lt;/P&gt;&lt;P&gt;client_id=XXXX;&lt;/P&gt;&lt;P&gt;client_secret = XXXX;&lt;/P&gt;&lt;P&gt;Grant_type =&amp;nbsp;&lt;SPAN&gt;client_credentials&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Headers :&amp;nbsp;Content-Type =&amp;nbsp;application/x-www-form-urlencoded&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Authorisation : Type = OAUTH 2.0 Request Header.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In SAS, i met some difficulties. I tried to use the code mentioned above.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfornutally, i have a bad request with a invalid_client resp.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;filename resptkn temp;&lt;BR /&gt;filename headers temp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc http&lt;BR /&gt;method="POST"&lt;BR /&gt;url="https://services-xxxxxxxxxxxxxx/token"&lt;BR /&gt;ct="application/x-www-form-urlencoded"&lt;BR /&gt;in='client_id=XXXX&amp;amp;client_secret=XXXX&amp;amp;grant_type=client_credentials'&lt;BR /&gt;headerout=headers&lt;BR /&gt;out=resptkn&lt;BR /&gt;HEADEROUT_OVERWRITE&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;{"error":"invalid_client"}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I used this proc to connect SAS with GA api or salesforce and i didnt' met issu..&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Do you have an idea ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Feb 2020 15:34:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Cannot-get-Proc-HTTP-to-return-Access-Token-via-REST-API/m-p/625305#M184296</guid>
      <dc:creator>Jejeremy87</dc:creator>
      <dc:date>2020-02-17T15:34:53Z</dc:date>
    </item>
  </channel>
</rss>

