首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google应用组设置API ::500后端错误

Google应用组设置API ::500后端错误
EN

Stack Overflow用户
提问于 2014-01-09 11:59:08
回答 1查看 979关注 0票数 0

每当我尝试从我们的Google Apps实例访问组时,我都会得到以下响应:

代码语言:javascript
复制
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "backendError",
    "message": "Backend Error"
   }
  ],
  "code": 500,
  "message": "Backend Error"
 }
}

我使用的代码如下:

代码语言:javascript
复制
begin
  require 'google/api_client'
rescue LoadError
  puts "You need the google-api-ruby-client gem..."
  puts "$ gem install google-api-client"
  exit 1
end

client = Google::APIClient.new(application_name: "Group Modifier")

## Use key to authenticate and generate token
key = Google::APIClient::PKCS12.load_key("#{File.dirname(__FILE__)}/mykey.p12", 'notasecret')
service_account = Google::APIClient::JWTAsserter.new(
  'mydeveloperid@developer.gserviceaccount.com',
  'https://www.googleapis.com/auth/apps.groups.settings',
  key)

client.authorization = service_account.authorize

groupssettings = client.discovered_api('groupssettings', 'v1')

result = client.execute(
    :api_method => groupssettings.groups.get,
    :parameters => { 'groupUniqueId' => 'mygroup@mydomain.com', 'alt' => 'json' }
)

puts result.body

我已经在Google Apps管理控制台和https://cloud.google.com/console中的"Manage API client access“中添加了正确的权限。

我甚至注意到当我使用"https://developers.google.com/admin-sdk/groups-settings/v1/reference/groups/get#try-it“时,它不会返回任何东西。

请帮帮我

EN

回答 1

Stack Overflow用户

发布于 2014-01-10 03:53:15

我最终通过使用git repo主页上的一些示例代码解决了我的问题。这是我想出来的:

代码语言:javascript
复制
begin
  require 'google/api_client'
rescue LoadError
  puts "You need the google-api-ruby-client gem..."
  puts "$ gem install google-api-client"
  exit 1
end

client = Google::APIClient.new

key = Google::APIClient::KeyUtils.load_from_pkcs12("#{File.dirname(__FILE__)}/mykey.p12", 'notasecret')
client.authorization = Signet::OAuth2::Client.new(
  :token_credential_uri => 'https://accounts.google.com/o/oauth2/token',
  :audience => 'https://accounts.google.com/o/oauth2/token',
  :scope => 'https://www.googleapis.com/auth/apps.groups.settings',
  :issuer => 'mydeveloperid@developer.gserviceaccount.com',
  :person => 'myemail@mydomain.com',
  :signing_key => key)
client.authorization.fetch_access_token!

groupssettings = client.discovered_api('groupssettings', 'v1')

result = client.execute(
    :api_method => groupssettings.groups.get,
    :parameters => { :groupUniqueId => 'mygroup@mydomain.com', :alt => 'json' }
)

puts result.body
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21011354

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档