54 %macro mv_tokenrefresh(inds=mv_registerclient
55 ,outds=mv_tokenrefresh
57 ,client_secret=somesecret
58 ,grant_type=authorization_code
61 ,access_token_var=ACCESS_TOKEN
62 ,refresh_token_var=REFRESH_TOKEN
64 %global &access_token_var &refresh_token_var;
65 options noquotelenmax;
70 %mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password)
72 ,msg=%str(Invalid value
for grant_type: &grant_type)
75 %mp_abort(iftrue=(&grant_type=password and (%str(&user)=%str() or %str(&pass)=%str()))
77 ,msg=%str(username / password required)
80 %
if %mf_existds(&inds) %then %
do;
83 call symputx(
'client_id',client_id,
'l');
84 call symputx(
'client_secret',client_secret,
'l');
85 call symputx(
"&refresh_token_var",&refresh_token_var,
'l');
89 %mp_abort(iftrue=(%str(&client_id)=%str() or %str(&client_secret)=%str())
91 ,msg=%str(client / secret must both be provided)
98 %let base_uri=%mf_getplatform(VIYARESTAPI);
100 %let fref1=%mf_getuniquefileref();
101 proc http method=
'POST'
102 in=
"grant_type=refresh_token%nrstr(&)refresh_token=&&&refresh_token_var"
104 url=
"&base_uri/SASLogon/oauth/token"
105 WEBUSERNAME=
"&client_id"
106 WEBPASSWORD=
"&client_secret"
108 headers
"Accept"=
"application/json"
109 "Content-Type"=
"application/x-www-form-urlencoded";
117 %let libref=%mf_getuniquelibref();
118 libname &libref JSON fileref=&fref1;
123 call symputx(
"&access_token_var",access_token);
124 call symputx(
"&refresh_token_var",refresh_token);
128 libname &libref clear;
129 filename &fref1 clear;