未定义的局部变量或方法`key' for Google :: Auth :: DefaultCredentials:Class

时间:2015-07-13 16:05:49

标签: google-api-ruby-client

当我这样做时:

scopes =  ['https://www.googleapis.com/auth/contacts.readonly']
contacts = Google::Apis::MirrorV1::MirrorService.new
something = Google::Auth.get_application_default(scopes)

我进入第3行:

  

无法读取指定的凭据文件   GOOGLE_APPLICATION_CREDENTIALS:未定义的局部变量或方法   `键' for Google :: Auth :: DefaultCredentials:Class

我从开发者控制台下载json文件,该文件具有以下结构:

{
  "web": {
    "client_id": "...",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "token_uri": "https://accounts.google.com/o/oauth2/token",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
    "client_email": "",
    "client_x509_cert_url": "",
    "client_secret": "...",
    "redirect_uris": [
      "http://localhost:3000/...",
      "http://localhost:3000/..."
    ],
    "javascript_origins": [
      "http://localhost:3000"
    ]
  }
}

并设置指向.json文件的GOOGLE_APPLICATION_CREDENTIALS环境变量。

我不确定为什么会收到错误。

先谢谢

0 个答案:

没有答案