Google 云端硬盘服务帐户和“请求中的未经授权的客户端或范围" [英] Google drive service account and “Unauthorized client or scope in request”

查看:33
本文介绍了Google 云端硬盘服务帐户和“请求中的未经授权的客户端或范围"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Google Developer Console 中的 Google_Client.php 类示例通过服务调用将文件上传到 Google Drive 帐户.2 个月前,我使用在开发者控制台中设置的服务帐户和预先设置的 Google 云端硬盘帐户成功地做到了这一点.

I am trying to upload files to a Google Drive account via a service call using the Google_Client.php class sample from the Google Developer Console. 2 months ago I did this successfully using a service account set up in the Developer Console, and a Google Drive account previsouly set up.

我现在正在尝试使用新的服务帐户和云端硬盘帐户执行相同的操作,但在标题中出现错误.据我所知,我所做的一切都是一样的.我的研究表明,我需要授予服务帐户电子邮件地址访问 Google 驱动器上目录的权限,但我终生不知道如何做到这一点.

I am now trying to do the same thing with a new service account and Drive account, but I get the error in the title. As far as I can tell I'm doing everything the same. My research suggests that I need to give the service account email addres access to a directory on Google drive, but I can't find out for the life of me how to do that.

我可以想象这在我第一次这样做时起作用的唯一原因是,对于该帐户,我首先将其设置为网络应用程序而不是服务帐户,并使用我的浏览器的同意屏幕来批准驱动器帐户访问权限.

The only reason I can imagine that this worked the first time I did this is that for that account I first set it up as a web application rather than a service account, and used the consent screen a my browser to approve the Drive account access.

顺便说一句 - 我在 stackoverflow 上检查了其他类似的帖子,但没有任何帮助.为这篇文章交叉手指.

BTW - I have checked other similar posts on stackoverflow, and none have helped. Cross fingers for this post.

推荐答案

老问题之类的,但另一个答案中的链接已失效.

Old question and all that, but the link in the other answer is dead.

我的研究表明,我需要授予服务帐户电子邮件地址访问 Google 驱动器上目录的权限,但我终生不知道如何做到这一点.

My research suggests that I need to give the service account email address access to a directory on Google drive, but I can't find out for the life of me how to do that.

获得电子邮件地址后,您可以通过 Google Drive UI 执行此操作:

You can do this through the Google Drive UI after you have the email address:

  1. https://console.developers.google.com/获取服务帐户的电子邮件地址api/凭据
  2. 在 Google 云端硬盘中,导航到您要共享的文件夹
  3. 右键单击文件夹
  4. 点击分享"
  5. 输入您在第 1 步中获得的电子邮件地址,然后点击完成".

这篇关于Google 云端硬盘服务帐户和“请求中的未经授权的客户端或范围"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆