33 %macro mv_getusergroups(user
34 ,outds=work.mv_getusergroups
35 ,access_token_var=ACCESS_TOKEN
36 ,grant_type=sas_services
39 %
if &grant_type=detect %then %
do;
40 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
41 %
else %let grant_type=sas_services;
43 %
if &grant_type=sas_services %then %
do;
44 %let oauth_bearer=oauth_bearer=sas_services;
45 %let &access_token_var=;
47 %put &sysmacroname: grant_type=&grant_type;
48 %mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
49 and &grant_type ne sas_services
52 ,msg=%str(Invalid value
for grant_type: &grant_type)
54 options noquotelenmax;
57 %let base_uri=%mf_getplatform(VIYARESTAPI);
61 %let fname1=%mf_getuniquefileref();
62 %let libref1=%mf_getuniquelibref();
64 proc http method=
'GET' out=&fname1 &oauth_bearer
65 url=
"&base_uri/identities/users/&user/memberships?limit=10000";
67 %
if &grant_type=authorization_code %then %
do;
68 "Authorization"=
"Bearer &&&access_token_var"
70 "Accept"=
"application/json";
73 %
if &SYS_PROCHTTP_STATUS_CODE=404 %then %
do;
74 %put NOTE: User &user not found!!;
77 %mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
79 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
82 libname &libref1 JSON fileref=&fname1;
89 filename &fname1 clear;
90 libname &libref1 clear;