【发布时间】:2021-04-06 12:26:31
【问题描述】:
我需要将收到的所有反馈都放在 Google 表格中。我正在关注article 来执行此操作,但问题是,如果我按照文章进行操作,则每次需要将某些内容添加到 Google 工作表时,我都必须手动允许访问我的项目。我知道我可以使用 google 服务帐户绕过手动验证,但我不能。我与服务帐户共享 Google 表格并使用服务帐户的 json 并收到错误。
JSON:
{
"web": {
"type": "service_account",
"project_id": "demoproject",
"private_key_id": "*********************",
"private_key": "************************",
"client_email": "writedata@demoproject.iam.gserviceaccount.com",
"client_id": "107266171145536070455",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/writedata%40demosheetproject.iam.gserviceaccount.com"
}
}
Error:
The redirect URI in the request, http://localhost:50936/Callback, does not match the ones authorized for the OAuth client. To update the authorized redirect URIs, visit: https://console.developers.google.com/apis/credentials/oauthclient/${your_client_id}?project=${your_project_number}
即使我已将 http://localhost/Callback 添加到 Google Cloud Console -> Credentials -> Authorized redirect URIs,我仍然会收到此错误。
所以我使用这个 Json
{
"web":
{
"client_id":"**********.apps.googleusercontent.com",
"project_id":"demoproject",
"auth_uri":"https://accounts.google.com/o/oauth2/auth",
"token_uri":"https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs",
"client_secret":"***********",
"redirect_uris":["http://localhost:61055"],
"javascript_origins":["http://localhost:61055"]
}
}
现在数据已填充到 Google 表格中,但该项目要求用户登录并授予其每次与 Google 表格交互的权限。
请建议我能做什么。任何帮助将不胜感激。
【问题讨论】:
标签: java google-cloud-platform google-sheets-api