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
Hi @eramirez
Have a look at these three papers
They should have what you are looking for and more
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;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.