如何使用Java API创建和访问Gmail帐户详细信息? [英] How to Create And Access Gmail Account Details using Java APIs?
问题描述
我想使用Java API创建一个Gmail帐户,并且还想访问现有gmail用户的基本详细信息.我尝试了很多站点,但无法编写代码.帮我提供代码段
I want to create a gmail account using java APIs and also want to access the basic details of the existing gmail user. I tried a lot of sites but not able to write a code. help me with a code snippet
先谢谢您
推荐答案
据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.
Lastly, to help you with the Java implementation, you may refer to the solution given in this SO post.
祝您编程愉快!
这篇关于如何使用Java API创建和访问Gmail帐户详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!