私は自分のウェブサイトでGoogleからの承認を得ようとしています。 Google oauthが「コードは既に使用されました」エラーで失敗するエラー
そしてaccess_token
にcode
を交換する工程で
redirect_uri = 'http://example.com/accounts/google/login/callback/'
config = {u'web': {u'redirect_uris': redirect_uris,
u'token_uri': u'https://accounts.google.com/o/oauth2/token',
u'auth_uri': u'https://accounts.google.com/o/oauth2/auth',
u'client_id': client_id,
u'client_secret': client_secret,
}
}
flow = google_auth_oauthlib.flow.Flow.from_client_config(
config,
scopes=['https://www.googleapis.com/auth/userinfo.profile', 'https://www.googleapis.com/auth/userinfo.email']
)
flow.redirect_uri = redirect_uri
flow.fetch_token(code=code)
Iを:それは、GoogleのLIBSとコードが推奨する使用してようdjango-allauth
libのaswellを使用して起こる
Code was already redeemed
私のローカルマシンでlocalhost urlでテスト設定を使用していますが、認証は正常に動作します。
しかし、プロダクションサーバーを使用するとエラーが発生します。 GoogleのWebアプリケーションで
私はURIをリダイレクトしている両方:私が見ることができるように、
http://localhost:8888/accounts/google/login/callback/
http://example.com/accounts/google/login/callback/
をcode
は一度だけexahnging、それが起こる可能性があり、それを修正する方法をなぜですか?
を使用してそれを解決リフレッシュする必要期限切れの短命のコードのように思えます。 [ヘルプ](https://stackoverflow.com/questions/32705682/google-api-php-offline-access-invalid-grant-code-was-already-reemed)リフレッシュトークンを使用していますか? – Jarad
実際には、 'fetch_token'(両方のトークンが来るはずです)が失敗するため、リフレッシュトークンを取得できません。短命の 'code'について:docsの情報が見つかりませんでした。 – user1931780