41%macro mv_getusergroups(user
42 ,outds=work.mv_getusergroups
43 ,access_token_var=ACCESS_TOKEN
44 ,grant_type=sas_services
47%
if &grant_type=detect %then %
do;
48 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
49 %
else %let grant_type=sas_services;
51%
if &grant_type=sas_services %then %
do;
52 %let oauth_bearer=oauth_bearer=sas_services;
53 %let &access_token_var=;
55%put &sysmacroname: grant_type=&grant_type;
56%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
57 and &grant_type ne sas_services
60 ,msg=%str(Invalid value
for grant_type: &grant_type)
65%let base_uri=%mf_getplatform(VIYARESTAPI);
69%let fname1=%mf_getuniquefileref();
70%let libref1=%mf_getuniquelibref();
72proc http method=
'GET' out=&fname1 &oauth_bearer
73 url=
"&base_uri/identities/users/&user/memberships?limit=10000";
75%
if &grant_type=authorization_code %then %
do;
76 "Authorization"=
"Bearer &&&access_token_var"
78 "Accept"=
"application/json";
84%
if &SYS_PROCHTTP_STATUS_CODE=404 %then %
do;
85 %put NOTE: User &user not found!!;
87 length ordinal_root 8 ordinal_items 8 version 8
88 id $256 implicit 8 name $256 providerId $32;
89 call missing(of _all_);
92 filename &fname1 clear;
96 %mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
98 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
101libname &libref1 JSON fileref=&fname1;
107 length ordinal_root 8 ordinal_items 8 version 8
108 id $256 implicit 8 name $256 providerId $32;
113filename &fname1 clear;
114libname &libref1 clear;
116%mend mv_getusergroups;