Macros for SAS Application Developers
No Matches 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:

[in]inds=A dataset containing client_id, client_secret, and auth_code
[in]outds=A dataset containing access_token and refresh_token
[in]client_id=The client name
[in]client_secret=client secret
[in]grant_type=valid values are "password" or "authorization_code" (unquoted). The default is authorization_code.
[in]code=() If grant_type=authorization_code then provide the necessary code here
[in]user=If grant_type=password then provide the username here
[in]pass=If grant_type=password then provide the password here
[in]access_token_var=(ACCESS_TOKEN) The global macro variable to contain the access token
[in]refresh_token_var=(REFRESH_TOKEN) The global macro variable to contain the refresh token
[in]base_uri=The Viya API server location
VIYA V.03.04
Allan Bowe, source:

SAS Macros

Definition in file