404 Resource Not Found: domain with Google Directory API

一曲冷凌霜 提交于 2019-12-01 11:06:01

After a bit of documentation reading, there were two things that I needed to fix.

  1. I hadn't set up the proper authorization for my test service account.

You have to go to the Apps Console > Security > Advanced > Manage API client access and add the client url for your service account as well as any specific permissions that you want to add

  1. As seen in this question, it seems that you need to create a user object rather than just passing in parameters.

Here's my updated code:

# Authorization happens here ....

api = client.discovered_api('admin', 'directory_v1')
new_user = api.users.insert.request_schema.new(
    name: { familyName: 'Testy', givenName: 'Testerson' },
    primaryEmail: 'ttttesterson@<domain-redacted>.com',
    password: 'password123'
 )

  result = client.execute(
    api_method: api.users.insert,
    body_object: new_user
 )
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!