Puisque vous utilisez Python pour authentifier les utilisateurs, vous pouvez essayer d'utiliser la oauth2client-library for Python sur la façon d'utiliser les objets de flux dans l'authentification:
flow_from_clientsecrets()
Les oauth2client.client.flow_from_clientsecrets () crée un objet Flow à partir d'un fichier client_secrets.json. Ce fichier au format JSON stocke votre ID client, secret client et autres paramètres OAuth 2.0.
L'exemple suivant montre comment vous pouvez utiliser flow_from_clientsecrets()
pour créer un objet de flux:
aide flow_from_clientsecrets()
from oauth2client.client import flow_from_clientsecrets
...
flow = flow_from_clientsecrets('path_to_directory/client_secrets.json',
scope='https://www.googleapis.com/auth/calendar',
redirect_uri='http://example.com/auth_return')
En utilisant OAuth2WebServerFlow
Malgré son nom, la classe oauth2client.client.OAuth2WebServerFlow
est utilisé pour les applications installées et Web. Il est créé en transmettant l'ID client, le secret client et la portée à son constructeur: Vous fournissez au constructeur un paramètre redirect_uri
. Cela doit être un URI géré par votre application.
from oauth2client.client import OAuth2WebServerFlow
...
flow = OAuth2WebServerFlow(client_id='your_client_id',
client_secret='your_client_secret',
scope='https://www.googleapis.com/auth/calendar',
redirect_uri='http://example.com/auth_return')
Cette question sera résolu le problème de l'authentification http://stackoverflow.com/questions/10271110/python-oauth2-login-with-google/10546639#10546639 – user5594493