56%macro mv_tokenrefresh(inds=mv_registerclient
57 ,outds=mv_tokenrefresh
59 ,client_secret=somesecret
60 ,grant_type=authorization_code
63 ,access_token_var=ACCESS_TOKEN
64 ,refresh_token_var=REFRESH_TOKEN
66%global &access_token_var &refresh_token_var;
72%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password)
74 ,msg=%str(Invalid value
for grant_type: &grant_type)
78 iftrue=(&grant_type=password and (%str(&user)=%str() or %str(&pass)=%str()))
80 ,msg=%str(username / password required)
83%
if %mf_existds(&inds) %then %
do;
86 call symputx(
'client_id',client_id,
'l');
87 call symputx(
'client_secret',client_secret,
'l');
88 call symputx(
"&refresh_token_var",&refresh_token_var,
'l');
92%mp_abort(iftrue=(%str(&client_id)=%str() or %str(&client_secret)=%str())
94 ,msg=%str(client / secret must both be provided)
101%let base_uri=%mf_getplatform(VIYARESTAPI);
103%let fref1=%mf_getuniquefileref();
104proc http method=
'POST'
105 in=
"grant_type=refresh_token%nrstr(&)refresh_token=&&&refresh_token_var"
107 url=
"&base_uri/SASLogon/oauth/token"
108 WEBUSERNAME=
"&client_id"
109 WEBPASSWORD=
"&client_secret"
111 headers
"Accept"=
"application/json"
112 "Content-Type"=
"application/x-www-form-urlencoded";
120%let libref=%mf_getuniquelibref();
121libname &libref JSON fileref=&fref1;
126 call symputx(
"&access_token_var",access_token);
127 call symputx(
"&refresh_token_var",refresh_token);
131libname &libref clear;
132filename &fref1 clear;
134%mend mv_tokenrefresh;