2

我正在尝试将 google-api gem 之类的命令与预测 API 一起使用。我想我一直在这样做,就像我一直在阅读的那样,但它一直给我错误“缺少访问令牌”。

首先,我通过 oauth1 进行身份验证。它把我带到我登录并授予访问权限的登录页面。登录后,它会关闭,并且在其中创建了一个文件,~/.google-api.yaml其中包含token_credential_secrettoken_credential_key

google-api oauth-1-login --scope https://www.googleapis.com/auth/prediction

我现在应该被认证不是吗?当我尝试执行命令时,它得到Missing Access Token.

google-api execute prediction.training.insert "data=bucket/train.csv"

我一直在网上搜索这个答案,但运气不佳。谷歌的文档通常不是最新的也无济于事。

4

1 回答 1

3

我删除了过期的文档。如果您发现其他过时的内容,请告诉我。主要问题只是我一直是构建 Ruby 客户端的人,现在我要搬到肯尼亚,接管它的人仍在增加。请多多包涵。

改为这样做:

bin/google-api oauth-2-login \
  --scope=https://www.googleapis.com/auth/prediction \
  --client-id=<your-client-id> \
  --client-secret=<your-client-secret>

然后您可以进行 API 调用:

google-api execute prediction.training.insert -- data=bucket/train.csv
于 2011-06-18T13:22:24.407 回答