问题描述
我使用 gdrive 和 gshell 与我的 Google 帐户交互并下载文件,获取他们的信息。
当我运行:gdrive about
或 gdown about
时,我收到以下消息
Initializing system (/home/user/.gdrive)
Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=...... \
apps.googleusercontent.com&redirect_uri=....
Enter verification code:
之后,当我在浏览器上粘贴以 https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=
开头的 URL 时,我不断收到以下错误消息:
This app is temporarily blocked from logging in with your Google account
。
==> 这个错误之前没有发生过,我能够收到 verification code
,以便用于连接到我的帐户。
是否有可能克服 Google 的这一障碍以使用 gdrive
或 gdown
?
生成token.json的例子,粘贴验证码后。
"access_token": ".....","token_type": "Bearer","refresh_token": "1/....","expiry": "2020-12-21T02:..."
}
解决方法
@tellowkrinkle 的 comment 帮我解决了这个问题。
可能是的。我有旧的二进制文件,谷歌阻止了它 进行身份验证,说这很危险,他们为我阻止了它 安全(非常感谢)。看来 Google 现在要求您让 他们审查想要访问敏感信息的应用程序 通过他们的 API
如果您想自己使用它,您需要:
- 转到 https://console.developers.google.com 并为自己创建一个新项目
- 在顶部的搜索框中搜索 Google Drive API,然后将其打开
- 点击左侧的 OAuth 同意屏幕并进行设置。
- 假设您的帐户不是组织的一部分,您将不得不说您的应用是供外部用户使用的并且正在测试中
- 在所需范围部分,添加 .../auth/docs 和 .../auth/drive(我不确定需要哪个,它可能只是其中之一 那些)。如果您没有完成 (2),这可能无法使用
- 添加您要与您的 gdrive 副本一起使用的帐户作为您应用的测试员。只有这些帐户才能使用您的副本 gdrive,所以每个人都必须编译自己的(除非有人 并让 Google 对其进行审核)
- 点击左侧的 Credentials,然后点击 Create Credentials,然后点击 OAuth 客户端 ID。应用类型为桌面应用
- 将客户端 ID 和 Secret 复制到 handlers_drive.go 的第 17 和 18 行并编译应用程序
$ git clone https://github.com/prasmussen/gdrive.git
$ cd gdrive
$ nano handlers_drive.go
# Copy the Client ID and Secret into handlers_drive.go lines 17 and 18 and compile the application
$ mv ~/.gdrive/token_v2.json ~/.gdrive/token_v2.json.old
$ go get github.com/prasmussen/gdrive
$ go build -ldflags "-w -s"
$ cp gdrive $GOPATH/bin/gdrive
$ gdrive about
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=.....
Enter verification code:
指南: