Skip to content

Commit

Permalink
Port PR #1054 by iamkhush
Browse files Browse the repository at this point in the history
  • Loading branch information
omab committed Dec 3, 2016
1 parent 7183357 commit a842f5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased](https://github.com/python-social-auth/social-core/commits/master)

### Added
- Added Shimmering backend (port from [#1054](https://github.com/omab/python-social-auth/pull/1054)
by iamkhush)
- Added Quizlet backend (port from [#1012](https://github.com/omab/python-social-auth/pull/1012)
by s-alexey)
- Added Dockerfile to simplify the running of tests (`make docker-tox`)
Expand Down
36 changes: 36 additions & 0 deletions social_core/backends/shimmering.py
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
)

0 comments on commit a842f5d

Please sign in to comment.