39 %macro mv_getapptoken(client_id=someclient
40 ,client_secret=somesecret
42 ,grant_type=authorization_code
44 %local consul_token fname1 fname2 fname3 libref access_token;
46 %mf_abort(iftrue=(&grant_type ne authorization_code and &grant_type ne password)
48 ,msg=%str(Invalid value
for grant_type: &grant_type)
53 infile
"%mf_loc(VIYACONFIG)/etc/SASSecurityCertificateFramework/tokens/consul/default/client.token";
55 call symputx(
'consul_token',token);
59 %let fname1=%mf_getuniquefileref();
60 filename &fname1 TEMP;
61 proc http method=
'POST' out=&fname1
62 url=
'http://localhost/SASLogon/oauth/clients/consul?callback=false&serviceId=app';
63 headers
"X-Consul-Token"=
"&consul_token";
66 %let libref=%mf_getuniquelibref();
67 libname &libref JSON fileref=&fname1;
72 call symputx(
'access_token',access_token);
79 %let fname2=%mf_getuniquefileref();
80 filename &fname2 TEMP;
83 clientid=quote(trim(symget(
'client_id')));
84 clientsecret=quote(trim(symget(
'client_secret')));
85 granttype=quote(trim(symget(
'grant_type')));
86 groups=symget(
'groups');
87 length grouplist $1024;
88 do x=1 to countw(groups);
89 grouplist=cats(grouplist,
",",quote(scan(groups,x)));
91 put
'{"client_id":' clientid
',"client_secret":' clientsecret
92 ',"scope": ["openid"' grouplist
93 '],"authorized_grant_types": [' granttype
',"refresh_token"],' 94 '"redirect_uri": "urn:ietf:wg:oauth:2.0:oob"}';
97 %let fname3=%mf_getuniquefileref();
98 filename &fname3 TEMP;
99 proc http method=
'POST' in=&fname2 out=&fname3
100 url=
'http://localhost/SASLogon/oauth/clients';
101 headers
"Content-Type"=
"application/json" 102 "Authorization"=
"Bearer &access_token";
112 %put Please provide the following details to the developer:;
114 %put CLIENT_ID=&client_id;
115 %put CLIENT_SECRET=&client_secret;
117 %
if &grant_type=authorization_code %then %
do;
118 %put The developer must also
register below and select
'openid' to
get the grant code:;
120 %put &SYSTCPIPHOSTNAME/SASLogon/oauth/authorize?client_id=&client_id%str(&)response_type=code;
125 filename &fname1 clear;
126 filename &fname2 clear;
127 filename &fname3 clear;
128 libname &libref clear;