I'm running the following code as part of the mv_registerclient macro for creating web services as described here.
proc http method='POST'
in="grant_type=refresh_token&refresh_token=&REFRESH_TOKEN" out=&FILEREF
url='localhost/SASLogon/oauth/token' WEBUSERNAME="&CLIENT_ID" WEBPASSWORD="&CLIENT_SECRET" AUTH_BASIC;
headers "Accept"="application/json" "Content-Type"="application/x-www-form-urlencoded";
run;
This code has worked perfectly for at least 6 months, in a number of different Viya environments. However today it threw:
{"error":"invalid_token","error_description":"Invalid token (approvals expired)"}
I generate a new client_id and client_secret every time I run the code, as I'm mainly doing demos or working with fresh installs. What could be the issue?
Oh, the story of our life 🙂
Great to hear!
You did well, not feeding him after midnight
Hi Allan / @AllanBowe
Interesting. As you might know, the token in an OAuth2 kind of token, therefore, it can be printed as JSON . Have you tried that?
Reason for me asking is because it is relatively common and well known: https://www.oauth.com/oauth2-servers/making-authenticated-requests/refreshing-an-access-token/
This can help you to get better control on token expiration mechanics.
The other possibility that comes to my mind is that there is a deeper issue in that system, which could invalidate tokens unexpectedly. For this is harder to provide guidance, as it could be given by time zone change, time change, updates (OS and/or SAS), etc.
Nonetheless, curl is your friend 🙂 As thumb rule: "Take things out of SAS, validate, then bring them back to SAS". Remove variables from the equation, then look at the logs.
I tried it again today, and it worked. Must have been a critter in a circuitboard somewhere 🙂
Oh, the story of our life 🙂
Great to hear!
You did well, not feeding him after midnight
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.