Google电子邮件设置api使用java中的OAuth 2.0服务帐户



我想使用Java中的OAuth2.0服务帐户身份验证方法来使用Google电子邮件设置api,但我无法从Google中找到任何有用的客户端类或有关如何做到这一点的示例。我已经看过目录api,它们对于用户或组相关的操作非常有用。有没有类似的电子邮件设置api?

您仍然可以将旧库AppsForYourDomainClient.jar与服务帐户一起使用。如果使用了用户/密码,您需要覆盖该方法,并设置您的GoogleCredential:

service = new GmailSettingsService(VERSION_HEADER, getDomain(), null, null) {
@Override
public void setUserCredentials(String username, String password)
        throws AuthenticationException {
    // Nothing to do here.
}};
service.setOAuth2Credentials(saCredential);

谷歌自己的库就在这里:https://github.com/google/google-oauth-java-client,如果y正在使用Maven的详细信息。

文档,包括示例,从这里开始:https://developers.google.com/api-client-library/java/google-oauth-java-client/

最新更新