开发者控制台中 google 项目的结构

Structure of google project in developer console

我正在为我的应用程序实施 Google Drive API 和 Google Sheets API。我应该如何在 Google 开发人员控制台中构建项目?

首先我为它创建了 Drive 连接和 Oauth2,然后用范围填充了验证请求

已验证。

然后我为 Sheets API 创建了另一个 Oauth2,并在尝试验证范围后

但是我的请求被拒绝了,消息是我已经有 https://www.googleapis.com/auth/drive.file 范围。

那么我应该为每个 API 创建单独的项目还是对它们都使用相同的 Oauth2?

每个应用程序都是 Google 开发者控制台中的一个项目。假设您正在尝试访问用户数据,那么您应该创建 Oauth2 凭据并请求应用程序所需的所有范围。

如果应用程序正在使用

然后您需要在 Google 开发者控制台中激活所有三个 API。但是我认为 drive.file 作用域使您能够以相同的方式访问 Google 驱动器中的所有文件,因此您不需要电子表格作用域。

https://www.googleapis.com/auth/drive.file View and manage Google Drive files and folders that you have opened or created with this app

https://www.googleapis.com/auth/spreadsheets View and manage your spreadsheets in Google Drive