首页 > 解决方案 > Multiple Google Account Authorization For Single Google Drive API

问题描述

Can I authorize multiple Google Accounts with single Google Drive API? Because when I am requesting this URI

https://accounts.google.com/o/oauth2/v2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive.metadata.readonly&access_type=offline&include_granted_scopes=true&state=teststate&redirect_uri=|+|redirecturi|+|&response_type=code&client_id=|+|clientid|+|

where |+|redirecturi|+| and |+|clientid|+| replaced by original one, so it is directly redirecting me to redirect_uri without opening consent screen.

标签: oauthgoogle-apigoogle-drive-apigoogle-oauth

解决方案


oauth2 的工作方式是用户必须登录到他们的谷歌帐户并授予您的应用程序访问他们数据的权限。返回给您的访问令牌绑定到用于创建它的客户端 ID。同意屏幕将显示给用户,代码将在重定向 uri 端点返回到您的应用程序

以下 url 为用户构建了一份同意书。

https://accounts.google.com/o/oauth2/auth?client_id= {clientid}.apps.googleusercontent.com&redirect_uri=urn:ietf:wg:oauth:2.0:oob&scope= https://www.googleapis.com/ auth/analytics.readonly&response_type=code

在此处输入图像描述

在这种情况下,要求他们授予您的应用程序“谷歌分析窗口”访问您的谷歌分析帐户的权限。在用户看到此表单之前,他们必须先登录。

回答者:

可以同意您的应用程序的用户数量没有限制。应向每个用户显示同意屏幕并授予您的应用程序访问权限,您将被授予访问他们数据的权限。


推荐阅读