BookmarkSubscribeRSS Feed
eramirez
Fluorite | Level 6

Hi,

 

I'm using the json libname engine with proc http to get data from a secure website.  I have the basic code working fine and I have a username and password to access the website, but now I have an API password and API key that I have to use now and can't find any documentation on how to incorporate it.  

filename out "C:\temp";

%let url =https://
%put url = &url;

proc http
url="&url"
method="get" out=out
WEBUSERNAME="&user"
WEBPASSWORD="&PW"
AUTH_BASIC;
run;

libname test JSON fileref=out;
filename mymap "C:\temp\test.map";
........

where do I add in the API password and API key or do I need the API password?  

sorry if this is basic, but I searched and found a lot of stuff for tokens, which are different than keys from what I read.  I read you can add the key to the URL or you can specify it in headers statement.  I feel like I'm close just nothing seems to be working.

if you can direct me to any documentation that would be great also.

thanks

Enrique

3 REPLIES 3
eramirez
Fluorite | Level 6
Thank you for the references, I did know of one of them already, but the other two seem promising.
ChrisHemedinger
Community Manager

If your API uses OAuth2 style tokens, you can use the special oath_bearer= option on PROC HTTP with your token. It's basically shorthand for "Authorization: Bearer your-oauth-token" in the HTTP header.

 

Ex:

proc http url= "your-api-call"
     method="GET"
     out=resp
     oauth_bearer="&access_token";
run;

 

For other token styles that use HTTP headers, use the HEADERS statement in PROC HTTP. It uses a name-value pair syntax like this:

 

    proc http
      url="https://your-api-query"  
      method="GET"
      out=resp
    ;
      headers 
        "Authorization"="Bearer &authtoken." 
        "session-key"="&sessionkey." ;
    run;

 

Become an Explorer! Join SAS Analytics Explorers to learn and complete challenges that earn rewards!

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

Explore Now →
How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1132 views
  • 2 likes
  • 3 in conversation