forked from python-social-auth/social-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
""" | ||
Shimmering Oauth | ||
""" | ||
from .oauth import BaseOAuth2 | ||
|
||
|
||
class ShimmeringOAuth2(BaseOAuth2): | ||
"""Shimmering Verify OAuth2 authentication backend""" | ||
name = 'shimmering' | ||
ID_KEY = 'id' | ||
AUTHORIZATION_URL = 'http://developers.shimmeringverify.com/o/authorize/' | ||
ACCESS_TOKEN_URL = 'http://developers.shimmeringverify.com/o/token/' | ||
ACCESS_TOKEN_METHOD = 'POST' | ||
|
||
def get_user_details(self, response): | ||
"""Return user details from Shimmering""" | ||
first_name = response.get('first_name') | ||
last_name = response.get('last_name') | ||
email = response.get('email') | ||
username = response.get('username') | ||
fullname = '{} {}'.format(first_name, last_name) | ||
return { | ||
'username': username, | ||
'fullname': fullname, | ||
'first_name': first_name, | ||
'last_name': last_name, | ||
'email': email, | ||
} | ||
|
||
def user_data(self, access_token, *args, **kwargs): | ||
"""Loads user data from service""" | ||
headers = {'Authorization': 'Bearer %s' % access_token} | ||
return self.get_json( | ||
'http://developers.shimmeringverify.com/user_info/', | ||
headers=headers | ||
) |