Skip to content

Commit 4dee22c

Browse files
committed
- Added identityset scope in native_example.py to get linked identities
- Added IdP side-loading in auth_example.py
1 parent c44b80d commit 4dee22c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

native_example.py

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
CLIENT_ID = '02a65a67-d996-4765-85b9-9522fb410d14'
66

77
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')
99

1010
authorize_url = client.oauth2_get_authorize_url()
1111
print('Please go to this URL and login: {0}\n'.format(authorize_url))
@@ -18,14 +18,22 @@
1818
token_response = client.oauth2_exchange_code_for_tokens(auth_code)
1919

2020
globus_auth_data = token_response.by_resource_server['auth.globus.org']
21-
globus_transfer_data = token_response.by_resource_server['transfer.api.globus.org']
2221

2322
# most specifically, you want these tokens as strings
2423
AUTH_TOKEN = globus_auth_data['access_token']
25-
TRANSFER_TOKEN = globus_transfer_data['access_token']
2624

2725
# Let the user know that he/she is authenticated
2826
ids = token_response.decode_id_token(client)
2927

3028
print("\n\nHere's what I know about you:\n")
3129
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

Comments
 (0)