我正在尝试使用 google admin api 进行授权并列出邮件列表用户。我从 api 控制台下载了一个密钥并做了:
require 'google/api_client'
client= Google::APIClient.new(application_name: "myapp", application_version: "0.1")
groups= client.discovered_api('admin', 'directory_v1')
key = Google::APIClient::PKCS12.load_key(Dir['*.p12'].first, '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/admin.directory.group.readonly',
issuer: '123asdf@developer.gserviceaccount.com',
signing_key: key)
client.authorization.fetch_access_token!
puts client.execute(api_method: groups.users.list, parameters: {}).body
我尝试添加 groupKey:“mygroup@googlegroups.com” 我尝试设置域:“mysite.com” 它总是导致“权限不足”
我还需要做什么才能列出组中的用户?