【发布时间】:2018-03-15 07:40:25
【问题描述】:
我有一个带有 python 服务器的 android 应用程序。我需要服务器能够不断访问用户的电子邮件,所以我正在遵循本指南:
https://developers.google.com/identity/sign-in/android/offline-access
def google_api(auth_token):
# If this request does not have X-Requested-With header, this could be a CSRF
#if not request.headers.get('X-Requested-With'):
#abort(403)
# Set path to the Web application client_secret_*.json file you downloaded from the
# Google API Console: https://console.developers.google.com/apis/credentials
CLIENT_SECRET_FILE = 'secret.json'
# Exchange auth code for access token, refresh token, and ID token
credentials = client.credentials_from_clientsecrets_and_code(
CLIENT_SECRET_FILE,
['https://www.googleapis.com/auth/gmail.readonly', 'profile', 'email'],
auth_token)
print credentials
return credentials.id_token
我收到以下错误: FlowExchangeError:redirect_uri_mismatch
这里是 secret.json:
{"web":{"client_id":"REDACTED",
"project_id":"REDACTED",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_secret":"REDACTED",
"redirect_uris":["http://localhost:8080/"],
"javascript_origins":["http://localhost:8080"]}}
我也尝试过使用http://my_actual_domain.com:5000/ 进行redirect_uris,但它仍然返回相同的错误。
我不明白 redirect_uris 应该是什么意思?我在顶部链接的指南中没有提到它
【问题讨论】:
标签: android python api web oauth