-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- closes #3
- Loading branch information
Javier Carnero
committed
May 18, 2018
1 parent
83ea5d3
commit b6c08ec
Showing
2 changed files
with
12 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,75 +25,21 @@ class KeyrockOAuth2(BaseOAuth2): | |
REDIRECT_STATE = False | ||
|
||
EXTRA_DATA = [ | ||
('id', 'uid'), | ||
('displayName', 'id'), | ||
('refresh_token', 'refresh_token'), | ||
('id', 'id'), | ||
('uid', 'uid'), | ||
# ('displayName', 'id'), | ||
# ('refresh_token', 'refresh_token'), | ||
('roles', 'roles'), | ||
('organizations', 'organizations'), | ||
('expires_in', 'expires') | ||
] | ||
|
||
def get_user_id(self, details, response): | ||
# ---- v5.4.0 | ||
# {'access_token': '53ERoBZXTDzjDrvSMAzEbLPW9JWX6f', | ||
# 'expires_in': 3600, | ||
# 'token_type': 'Bearer', | ||
# 'state': 'IVbDtzMyx9fZib77Eiwqb4jtBwFLxgt0', | ||
# 'scope': 'all_info', | ||
# 'refresh_token': 'VGyiMKgKMISjmUraVmMb8ALIrtYb3u', | ||
# 'organizations': [], | ||
# 'displayName': 'j*******', | ||
# 'roles': [{'name': 'Provider', 'id': 'provider'}], | ||
# 'app_id': '0db45bbbfe05409685c2e043892d7d00', | ||
# 'isGravatarEnabled': False, | ||
# 'email': 'j*****.c******@atos.net', | ||
# 'id': 'j*******'} | ||
# ---- v7.0.0 | ||
# {'access_token': '4bb8dee1ea3e1f4523623af71d52e265f05304f3', | ||
# 'token_type': 'Bearer', | ||
# 'expires_in': 3599, | ||
# 'refresh_token': 'd200de308c8694a3edde6afe9e19c89196754d29', | ||
# 'organizations': [], | ||
# 'displayName': 'jcarnero', | ||
# 'roles': [ | ||
# {'id': 'b6208353-cd6d-4443-ad55-2a34b4c6df4f', 'name': 'Developer'}, | ||
# {'id': '8a2fc748-d7d9-48b9-be17-2cad3c1140c3', 'name': 'User'}], | ||
# 'app_id': '390f1cbf-0582-4d65-aa93-531c3aed9a3f', | ||
# 'email': '[email protected]', | ||
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f', | ||
# 'app_azf_domain': ''}) | ||
return response['displayName'].replace('-', '_') | ||
print("--------->USER_ID: "+str(response)) | ||
return response['id'].replace('-', '_') | ||
|
||
def get_user_details(self, response): | ||
"""Return user details from FI-WARE account""" | ||
# ---- v5.4.0 | ||
# {'access_token': 'uN1mFJKd9m0pGMdLyRFdvew5VLFMs3', | ||
# 'expires_in': 3600, | ||
# 'token_type': 'Bearer', | ||
# 'state': 'HuQGmypp6QjjIcp4Izw097egFV1wd55f', | ||
# 'scope': 'all_info', | ||
# 'refresh_token': '35pOUhNnaUOEAicjyF4C8F9ZAa3jG8', | ||
# 'organizations': [], | ||
# 'displayName': 'j*******', | ||
# 'roles': [{'name': 'Provider', 'id': 'provider'}], | ||
# 'app_id': '0db45bbbfe05409685c2e043892d7d00', | ||
# 'isGravatarEnabled': False, | ||
# 'email': 'j*****.c******@atos.net', | ||
# 'id': 'j*******'} | ||
# ---- v7.0.0 | ||
# {'access_token': '4bb8dee1ea3e1f4523623af71d52e265f05304f3', | ||
# 'token_type': 'Bearer', | ||
# 'expires_in': 3599, | ||
# 'refresh_token': 'd200de308c8694a3edde6afe9e19c89196754d29', | ||
# 'organizations': [], | ||
# 'displayName': 'jcarnero', | ||
# 'roles': [ | ||
# {'id': 'b6208353-cd6d-4443-ad55-2a34b4c6df4f', 'name': 'Developer'}, | ||
# {'id': '8a2fc748-d7d9-48b9-be17-2cad3c1140c3', 'name': 'User'}], | ||
# 'app_id': '390f1cbf-0582-4d65-aa93-531c3aed9a3f', | ||
# 'email': '[email protected]', | ||
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f', | ||
# 'app_azf_domain': ''} | ||
return {'username': response.get('displayName').replace('-', '_'), | ||
'email': response.get('email') or ''} | ||
|
||
|
@@ -120,7 +66,11 @@ def user_data(self, access_token, *args, **kwargs): | |
# 'email': '[email protected]', | ||
# 'id': 'f8297ebc-4a60-4a43-9d74-cec472bbc01f', | ||
# 'app_azf_domain': ''} | ||
return self.get_json(url) | ||
response = self.get_json(url) | ||
response['uid'] = response['id'] | ||
response['id'] = response['displayName'].replace('-', '_') | ||
print("--------->USER_DATA: "+str(response)) | ||
return response | ||
|
||
def auth_headers(self): | ||
response = super(KeyrockOAuth2, self).auth_headers() | ||
|