使用Java中的OAuth 2.0服务帐户的Google电子邮件设置API [英] Google Email Settings api using OAuth 2.0 service account in java

查看:405
本文介绍了使用Java中的OAuth 2.0服务帐户的Google电子邮件设置API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Java中的OAuth2.0服务帐户身份验证方法使用Google Email Settings API,但是我无法从Google找到任何有用的客户端类或有关如何执行此操作的示例示例.我看过目录api,它对于与用户或组相关的操作非常有用.电子邮件设置API是否具有等效功能?

I want to use Google Email Settings api using OAuth2.0 service account authentication method in Java, however I am unable to find any useful client classes from Google or sample examples about how to do this. I have had a look at Directory apis which are very useful for user or group related operations. Is there any equivalent for Email Settings api?

推荐答案

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

You can still use the old library AppsForYourDomainClient.jar with Service Accounts. You need to override the method were the user/password are used and set your 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);

这篇关于使用Java中的OAuth 2.0服务帐户的Google电子邮件设置API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆