Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mv_tokenrefresh.sas File Reference

Get an additional access token using a refresh token. More...

Go to the source code of this file.

Detailed Description

Before an access token can be obtained, a refresh token is required For that, check out the mv_tokenauth macro.

Usage:

  prep work - register client, get refresh token, save it for later use ;
%mv_registerclient(outds=client)
%mv_tokenauth(inds=client,code=wKDZYTEPK6)
data _null_;
file "~/refresh.token";
put "&refresh_token";
run;

  now do the things n stuff;
data _null_;
  infile "~/refresh.token";
  input;
  call symputx('refresh_token',_infile_);
run;
%mv_tokenrefresh(client_id=&client
  ,client_secret=&secret
)

A great article for explaining all these steps is available here:

https://blogs.sas.com/content/sgf/2019/01/25/authentication-to-sas-viya/

Parameters
inds=A dataset containing client_id and client_secret
outds=A dataset containing access_token and refresh_token
client_id=The client name (alternative to inds)
client_secret=client secret (alternative to inds)
grant_type=valid values are "password" or "authorization_code" (unquoted). The default is authorization_code.
user=If grant_type=password then provide the username here
pass=If grant_type=password then provide the password here
access_token_var=The global macro variable to contain the access token
refresh_token_var=The global macro variable containing the refresh token
Version
VIYA V.03.04
Author
Allan Bowe @source https://github.com/sasjs/core

Dependencies

Definition in file mv_tokenrefresh.sas.