Recurso 404 não encontrado: domínio com a API do Google Directory

Eu segui o início rápido e estou tentando criar um usuário usando o google-api-ruby-client.

Eu configurei o acesso no console da API do Google. E posso fazer isso funcionar usando o API Explorer.

Mas quando tento usar o cliente ruby, estou obtendo um recurso não encontrado: erro de domínio.

Aqui está o código:

def self.create_user

# Initialize the client.
client = Google::APIClient.new(
  :application_name => 'MYAPP',
  :application_version => '0.0.1'
)

# Authorization
# Load our credentials for the service account
key = Google::APIClient::KeyUtils.load_from_pkcs12(KEY_FILE, KEY_SECRET)

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.user',
  issuer: ACCOUNT_ID,
  signing_key: key)

# Request a token for our service account
client.authorization.fetch_access_token!

# Load API Methods
admin = client.discovered_api('admin', 'directory_v1')

# Make an API call.
result = client.execute(
   admin.users.update,
    name: { familyName: 'testy', givenName: 'testerson' },
     password: '!password12345!',
     primaryEmail: '[email protected]'
)

result.data

fim

Aqui está a resposta:

"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"notFound", "message"=>"Resource Not Found: domain"}], "code"=>404, "message"=>"Resource Not Found: domain"}

Por quê?

questionAnswers(1)

yourAnswerToTheQuestion