|
5 | 5 | CLIENT_ID = '02a65a67-d996-4765-85b9-9522fb410d14' |
6 | 6 |
|
7 | 7 | client = globus_sdk.NativeAppAuthClient(CLIENT_ID) |
8 | | -client.oauth2_start_flow() |
| 8 | +client.oauth2_start_flow(requested_scopes='openid email profile urn:globus:auth:scope:auth.globus.org:view_identity_set') |
9 | 9 |
|
10 | 10 | authorize_url = client.oauth2_get_authorize_url() |
11 | 11 | print('Please go to this URL and login: {0}\n'.format(authorize_url)) |
|
18 | 18 | token_response = client.oauth2_exchange_code_for_tokens(auth_code) |
19 | 19 |
|
20 | 20 | globus_auth_data = token_response.by_resource_server['auth.globus.org'] |
21 | | -globus_transfer_data = token_response.by_resource_server['transfer.api.globus.org'] |
22 | 21 |
|
23 | 22 | # most specifically, you want these tokens as strings |
24 | 23 | AUTH_TOKEN = globus_auth_data['access_token'] |
25 | | -TRANSFER_TOKEN = globus_transfer_data['access_token'] |
26 | 24 |
|
27 | 25 | # Let the user know that he/she is authenticated |
28 | 26 | ids = token_response.decode_id_token(client) |
29 | 27 |
|
30 | 28 | print("\n\nHere's what I know about you:\n") |
31 | 29 | print(json.dumps(ids,indent=3)) |
| 30 | + |
| 31 | +# get the stored access token for the Auth API and use it |
| 32 | +# to authorize stuff AS THE AUTHENTICATED USER |
| 33 | +ac = globus_sdk.AuthClient(authorizer=globus_sdk.AccessTokenAuthorizer(AUTH_TOKEN)) |
| 34 | + |
| 35 | +# use Auth API to get the standard OIDC userinfo fields (like any OIDC client) |
| 36 | +oidcinfo = ac.oauth2_userinfo() |
| 37 | + |
| 38 | +print("\n\nAnd here's what oauth2_userinfo() returns:\n") |
| 39 | +print(json.dumps(oidcinfo.data,indent=3)) |
0 commit comments