4

我正在使用gdrivegshell与我的 Google 帐户交互并下载文件,获取他们的信息。

当我运行:gdrive aboutgdown 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, 以便用于连接到我的帐户。

是否有可能克服谷歌的这个障碍以便使用gdriveor gdown


生成token.json的例子,粘贴验证码后。

  "access_token": ".....",
  "token_type": "Bearer",
  "refresh_token": "1/....",
  "expiry": "2020-12-21T02:..."
}
4

1 回答 1

2

@tallowkrinkle 的评论帮助我解决了这个问题。

可能是。我有旧的二进制文件,谷歌阻止它进行身份验证,说它很危险,他们为了我的安全而阻止了它(非常感谢)。看起来谷歌现在要求你让他们审查想要通过他们的 API 访问敏感信息的应用程序

如果您想自己使用它,您需要:

  1. 转到https://console.developers.google.com并为自己创建一个新项目
  2. Google Drive API在顶部的搜索框中搜索并启用它
  3. 单击OAuth consent screen左侧并进行设置。
    • 假设您的帐户不是组织的一部分,您必须说您的应用程序是供external用户使用的并且正在测试中
    • 在所需的范围部分,添加.../auth/docs.../auth/drive(我不确定哪个需要,它可能只是其中之一)。如果您没有完成,这可能不可用 (2)
    • 添加您要与 gdrive 副本一起使用的帐户作为应用的测试人员。只有这些帐户才能使用您的 gdrive 副本,因此每个人都必须自己编译(除非有人去 Google 审查他们的)
  4. 单击Credentials左侧,然后单击 Create Credentials,然后单击 OAuth 客户端 ID。申请类型是Desktop app
  5. 将 Client 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 install github.com/prasmussen/gdrive@latest
$ 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:

指导:

于 2020-12-30T12:43:29.057 回答