Ho usato l'autenticazione social python per l'autenticazione social negli ultimi 2 mesi ed è stato fantastico. Ho bisogno del supporto QQ, quindi ho installato il più recente commit git (23e4e289ec426732324af106c7c2e24efea34aeb - non fa parte di una versione). finora ho usato per autenticare l'utente utilizzando il seguente codice:python social auth load strategy e autenticate manualmente l'utente con la versione 0.1.26
# setup redirect uri in order to load strategy
uri = redirect_uri = "social:complete"
if uri and not uri.startswith('/'):
uri = reverse(redirect_uri, args=(backend,))
# load the strategy
try:
strategy = load_strategy(
request=request, backend=backend,
redirect_uri=uri, **kwargs
)
strategy = load_strategy(request=bundle.request)
except MissingBackend:
raise ImmediateHttpResponse(HttpNotFound('Backend not found'))
# get the backend for the strategy
backend = strategy.backend
# check backend type and set token accordingly
if isinstance(backend, BaseOAuth1):
token = {
'oauth_token': bundle.data.get('access_token'),
'oauth_token_secret': bundle.data.get('access_token_secret'),
}
elif isinstance(backend, BaseOAuth2):
token = bundle.data.get('access_token')
else:
raise ImmediateHttpResponse(HttpBadRequest('Wrong backend type'))
# authenticate the user
user = strategy.backend.do_auth(token)
che funzionava bene.
Nell'ultima versione questo comportamento è stato modificato e viene sollevata un'eccezione poiché il metodo "load_strategy" è stato modificato.
Non riesco a trovare alcuna documentazione su come farlo con la nuova versione.
Qualsiasi aiuto sarebbe apprezzato!
Omri.
Grazie !! Questo è quello che stavo cercando! – OmriToptix