omab / python-social-auth

Social auth made simple
http://psa.matiasaguirre.net
BSD 3-Clause "New" or "Revised" License
2.83k stars 1.09k forks source link

Changing response type from 'code' to 'token' #984

Closed Paradoxis closed 7 years ago

Paradoxis commented 8 years ago

I'm writing a mobile app that requires a login using response_type=token instead of the default response_type=code, is there a way how I can set up my social login redirect link to use the token based login instead? I know it's possible to register using an access token (docs), but I can't seem to find out how I can append this to the URL before the user is redirected.

omab commented 7 years ago

You need to override the backend in use, let's assume Facebook OAuth2, the following override should be what you are looking for:


from social_core.backends.facebook import FacebookOAuth2

class FacebookOAuth2Token(FacebookOAuth2):
  name = 'facebook-token'
  RESPONSE_TYPE = 'token'

Add that backend to the AUTHENTICATION_BACKENDS setting and use the url /login/facebook-token.