Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Пример авторизационного бэкенда для клиента:
- from social.backends.oauth import BaseOAuth2
- class UNTIBackend(BaseOAuth2):
- name = 'sso_unti-oauth2'
- ID_KEY = 'username'
- AUTHORIZATION_URL = '{}/oauth2/authorize'.format(settings.SSO_UNTI_URL)
- ACCESS_TOKEN_URL = '{}/oauth2/access_token'.format(settings.SSO_UNTI_URL)
- USER_DATA_URL = '{url}/oauth2/access_token/{access_token}/'
- DEFAULT_SCOPE = []
- REDIRECT_STATE = False
- ACCESS_TOKEN_METHOD = 'POST'
- PIPELINE = (
- 'social.pipeline.social_auth.social_details',
- 'social.pipeline.social_auth.social_uid',
- 'social.pipeline.social_auth.auth_allowed',
- 'social.pipeline.social_auth.social_user',
- 'social.pipeline.user.get_username',
- 'social.pipeline.user.create_user',
- 'social.pipeline.social_auth.associate_user',
- 'social.pipeline.social_auth.load_extra_data',
- 'social.pipeline.user.user_details',
- )
- skip_email_verification = True
- def get_user_details(self, response):
- return response
- def user_data(self, access_token, *args, **kwargs):
- return self.get_json(
- '{}/users/me'.format(settings.SSO_UNTI_URL),
- params={'access_token': access_token},
- headers={'Authorization': 'Bearer {}'.format(access_token)},
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement