33%macro mv_getgroups(access_token_var=ACCESS_TOKEN
34 ,grant_type=sas_services
35 ,outds=work.viyagroups
37%local oauth_bearer base_uri fname1 libref1;
38%
if &grant_type=detect %then %
do;
39 %
if %symexist(&access_token_var) %then %let grant_type=authorization_code;
40 %
else %let grant_type=sas_services;
42%
if &grant_type=sas_services %then %
do;
43 %let oauth_bearer=oauth_bearer=sas_services;
44 %let &access_token_var=;
47%mp_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password
48 and &grant_type ne sas_services
51 ,msg=%str(Invalid value
for grant_type: &grant_type)
56%let base_uri=%mf_getplatform(VIYARESTAPI);
59%let fname1=%mf_getuniquefileref();
60%let libref1=%mf_getuniquelibref();
62proc http method=
'GET' out=&fname1 &oauth_bearer
63 url=
"&base_uri/identities/groups?limit=10000";
65 %
if &grant_type=authorization_code %then %
do;
66 "Authorization"=
"Bearer &&&access_token_var"
68 "Accept"=
"application/json";
71%mp_abort(iftrue=(&SYS_PROCHTTP_STATUS_CODE ne 200)
73 ,msg=%str(&SYS_PROCHTTP_STATUS_CODE &SYS_PROCHTTP_STATUS_PHRASE)
75libname &libref1 JSON fileref=&fname1;
83filename &fname1 clear;
84libname &libref1 clear;