且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用Java API创建和访问Gmail帐户详细信息?

更新时间:2023-12-04 09:30:22

Gmail API文档显示,此API尚未添加Gmail帐户创建功能.当前,您可以使用Gmail API添加Gmail功能,例如:

As far as the Gmail API documentation shows, creation of Gmail account isn't an added feature yet for this API. Currently, you can use Gmail API to add Gmail features like:

  • 从Gmail阅读邮件
  • 发送电子邮件
  • 修改应用于消息和线程的标签
  • 搜索特定的消息和主题
  • 创建过滤器以自动标记,转发或存档邮件

因此,如果您要创建用户帐户,则可以选择使用授权请求中所述的授权,您可以可以使用以下格式发送HTTP请求:

So, if you wish to create a user account, an option that you can do is to use the Users: insert of Google Apps Admin SDK - Directory API. With the inclusion of the authorization described in Authorize requests, you may send HTTP request using the following format:

POST https://www.googleapis.com/admin/directory/v1/users

在请求正文中,为用户的资源提供文档中提供的可用属性.

In the request body, supply user's resources with the available properties that are given in the documentation.

同样,您也可以使用目录API:用户帐户.您可以使用 GET 请求检索用户,并包括授权.格式为:

Likewise, you can access the basic details of an existing gmail user also with the use of Directory API: User Accounts. You can retrieve a user using the GET request and include also the authorization. Format is:

GET https://www.googleapis.com/admin/directory/v1/users/userKey

  • userKey 可以是用户的主要电子邮件地址,唯一的用户ID或用户的别名电子邮件地址之一.
    • userKey can be the user's primary email address, the unique user id, or one of the user's alias email addresses.
    • 如果请求成功,则返回带有 HTTP 200状态代码和用户帐户属性的JSON响应.

      If request is successful, this returns a JSON response with HTTP 200 status code and the properties for the user account.

      有关更多信息,请查看给定的文档.

      For more information, please check the given documentations.

      最后,为了帮助您实现Java,您可以参考此

      Lastly, to help you with the Java implementation, you may refer to the solution given in this SO post.

      祝您编程愉快!