【问题标题】:Rails Signet Client & Admin SDK/Directory APIRails Signet 客户端和管理 SDK/目录 API
【发布时间】:2013-05-28 17:21:05
【问题描述】:

我在 Rails 应用程序中使用 Google Signet Client 来访问 Google API,现在主要是通过 OAuth 1 访问 Provisioning API。Google 刚刚推出了一组新的 API,名称为 Admin SDK。具体来说,我对Directory API 的功能感兴趣。不幸的是,Directory API 不断通过 signet 客户端返回“Invalid Credentials”响应。

我的 OAuth 身份验证通过 Google Marketplace 进行,以执行密钥等操作。下面是代码如何生成客户端的示例:

oauth_args = {
  :authorization_uri => "https://www.google.com/accounts/OAuthAuthorizeToken",
  :token_credential_uri =>"https://www.google.com/accounts/OAuthGetAccessToken",
  :client_credential_key => < google_marketplace_consumer_key >,
  :client_credential_secret => < google_marketplace_consumer_secret >
}

client = Signet::OAuth1::Client.new(oauth_args)
client.two_legged = true
client.requestor_id = self.owner.email
client.get(:uri=>'https://www.googleapis.com/admin/directory/v1/users?key=<api key>&domain=< my test domain >')

奇怪的是,同样的请求在 OAuth1 操场上工作得很好,使用我在本地环境中使用的相同测试密钥,但每次我点击目录 API 时,我都会得到相同的“无效凭据”。另请注意,除了请求的 URL 之外,这与我用于访问 Provisioning API 的代码相同。

任何人都知道为什么这个 API 似乎与客户端或我的身份验证方式有问题吗?我已为我的帐户启用 API。

【问题讨论】:

    标签: ruby-on-rails google-api google-admin-sdk


    【解决方案1】:

    最终与signet客户端无关,仅与Google Marketplace权限有关; “无效凭据”错误更像是一条红鲱鱼。是否按照Migrate application developed with the Provisioning API to the new api (Admin SDK) 中列出的步骤进行操作,并且有效;我已为我的应用启用 API,但尚未更新清单。

    【讨论】:

      猜你喜欢
      • 2020-08-05
      • 2016-08-21
      • 2021-06-01
      • 1970-01-01
      • 2018-06-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多