<?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: How to use API token in PROC HTTP: climate data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-API-token-in-PROC-HTTP-climate-data/m-p/879520#M347457</link>
    <description>&lt;P&gt;A couple of changes needed. According to the doc, the header should include "token: &amp;lt;your token&amp;gt;" -- it's not an OAuth style "Authorization: Bearer &amp;lt;token&amp;gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the endpoint is "locations", not "location".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let token=your-token-value;
filename resp temp;
proc http
 method="GET"
 out=resp
 url="https://www.ncei.noaa.gov/cdo-web/api/v2/locations?datasetid=GHCND";
 headers 
  "token" = "&amp;amp;token.";
run;

libname data JSON fileref=resp;

proc print data=data.results;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisHemedinger_0-1686138831705.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84769i770FAF0EDCEB4E69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisHemedinger_0-1686138831705.png" alt="ChrisHemedinger_0-1686138831705.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Jun 2023 11:54:00 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2023-06-07T11:54:00Z</dc:date>
    <item>
      <title>How to use API token in PROC HTTP: climate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-API-token-in-PROC-HTTP-climate-data/m-p/879495#M347447</link>
      <description>&lt;P&gt;I've read some articles on the forum but did not find the solution. My key problem is in understanding the technical specification provided on the following webpage and how to embed into SAS code:&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.ncdc.noaa.gov/cdo-web/webservices/v2#gettingStarted" target="_blank" rel="noopener"&gt;https://www.ncdc.noaa.gov/cdo-web/webservices/v2#gettingStarted&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In particular, it says the usage of token is:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;curl -H "token:&amp;lt;token&amp;gt;" "url"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;$.ajax({ url:&amp;lt;url&amp;gt;, data:{&amp;lt;data&amp;gt;}, headers:{ token:&amp;lt;token&amp;gt; } })&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've requested the token. Tried the following code:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let mytoken =BgGrhHFjqqfXkZugQhzPSsBSEanFm; *API token;
filename trial temp;
proc http 
out= trial verbose
method="GET" 
url= "https://www.ncei.noaa.gov/cdo-web/api/v2/location?datasetid=GHCND"; 
Headers
"Authorization" = "Bearer &amp;amp;mytoken.";
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;It tuns out "400 Bad request."&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Any help? or guidance?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 08:47:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-API-token-in-PROC-HTTP-climate-data/m-p/879495#M347447</guid>
      <dc:creator>Gigiwen</dc:creator>
      <dc:date>2023-06-07T08:47:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to use API token in PROC HTTP: climate data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-API-token-in-PROC-HTTP-climate-data/m-p/879520#M347457</link>
      <description>&lt;P&gt;A couple of changes needed. According to the doc, the header should include "token: &amp;lt;your token&amp;gt;" -- it's not an OAuth style "Authorization: Bearer &amp;lt;token&amp;gt;".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, the endpoint is "locations", not "location".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;%let token=your-token-value;
filename resp temp;
proc http
 method="GET"
 out=resp
 url="https://www.ncei.noaa.gov/cdo-web/api/v2/locations?datasetid=GHCND";
 headers 
  "token" = "&amp;amp;token.";
run;

libname data JSON fileref=resp;

proc print data=data.results;
run;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChrisHemedinger_0-1686138831705.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/84769i770FAF0EDCEB4E69/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ChrisHemedinger_0-1686138831705.png" alt="ChrisHemedinger_0-1686138831705.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Jun 2023 11:54:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-API-token-in-PROC-HTTP-climate-data/m-p/879520#M347457</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-06-07T11:54:00Z</dc:date>
    </item>
  </channel>
</rss>

