为 Google Sheets 设置授权码 OAuth 流
先决条件
-
您可以在登录后使用 Google Sheets 应用程序的 Google 账户。在您的 Google 账户中,Google Sheets 已包含要传输的数据。
-
一个 Google Cloud Platform 账户和 Google Cloud 项目。有关更多详细信息,请参阅 Create Google Cloud Project
。
要设置 Google 账户并获取 OAuth 2.0 凭证,请按以下步骤操作:
-
设置好 Google Cloud 项目后,在该项目中启用 Google Sheets API 和 Google Drive API。有关启用步骤,请参阅 Google Cloud Platform 的 API Console 帮助中的 Enable and disable APIs
。 -
然后为外部用户配置 OAuth 同意屏幕。有关 OAuth 同意屏幕的更多信息,请参阅 Google Cloud Platform Console 帮助中心中的 Setting up your OAuth consent screen
。 -
在 OAuth 同意屏幕中,添加以下范围:
有关这些范围的更多信息,请参阅 Google Identity 文档中的 OAuth 2.0 Scopes for Google APIs
。 -
生成 OAuth 2.0 客户端 ID 和密钥。有关创建此客户端 ID 的步骤,请参阅 Google Cloud Platform Console 帮助中的 Setting up OAuth 2.0
。 OAuth 2.0 客户端 ID 必须有一个或多个经过授权的重定向 URL。
重定向 URL 采用以下格式:
-
https://<aws-region>.console.aws.amazon.com/gluestudio/oauth
-
-
记下 OAuth 2.0 客户端 ID 设置中的客户端 ID 和客户端密钥。