Production Ready Macros for SAS Application Developers File Reference

Get initial Refresh and Access Tokens. More...

Go to the source code of this file.

Detailed Description

Before a Refresh Token can be obtained, the client must be registered by an administrator. This can be done using the mv_registerclient macro, after which the user must visit a URL to get an additional code (if using oauth).

That code (or username / password) is used here to get the Refresh Token (and an initial Access Token). THIS MACRO CAN ONLY BE USED ONCE - further access tokens can be obtained using the mv_gettokenrefresh macro.

Access tokens expire frequently (every 10 hours or so) whilst refresh tokens expire periodically (every month or so). This is all configurable.


filename mc url "";
%inc mc;



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

inds=A dataset containing client_id, client_secret, and auth_code
outds=A dataset containing access_token and refresh_token
client_id=The client name
client_secret=client secret
grant_type=valid values are "password" or "authorization_code" (unquoted). The default is authorization_code.
code=If grant_type=authorization_code then provide the necessary code here
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 to contain the refresh token
base_uri=The Viya API server location
VIYA V.03.04
Allan Bowe @source


Definition in file