Create users using Service Account with Google Admin SDK?

人走茶凉 提交于 2019-12-06 14:27:47

问题


The documentation is a little unclear on this. Can I actually do this? The only examples I've seen so far are from the Google documentation that show it using the GoogleAuthorizationCodeFlow class to gain authorization. I've seen a few examples of using the Service Account to update and retrieve a list of users, but nothing for creating. Is this possible? If so, does anyone know of any examples floating around? I can't seem to find anything that addresses it.


回答1:


You can follow the steps outlined in the following API docs page to create the service account and perform a domain wide delegation of authority, please bear in mind you need the email address of a domain administrator which the service account can act on their behalf:

https://developers.google.com/admin-sdk/directory/v1/guides/delegation

The page includes a Java example of how to instantiate a com.google.api.services.admin.directory.Directory object using the service account and private key created on the Google Developers Console. Then use the example I've provided in this answer to create the users:

Create gmail account for a domain using Google Admin SDK Directory API in Java



来源:https://stackoverflow.com/questions/26238087/create-users-using-service-account-with-google-admin-sdk

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