[英]Google Email Settings api using OAuth 2.0 service account in java
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. 我想使用Java中的OAuth2.0服务帐户身份验证方法使用Google Email Settings API,但是我无法从Google找到任何有用的客户端类或有关如何执行此操作的示例示例。 I have had a look at Directory apis which are very useful for user or group related operations. 我看过目录api,它对于与用户或组相关的操作非常有用。 Is there any equivalent for Email Settings api? 电子邮件设置API是否有等效功能?
You can still use the old library AppsForYourDomainClient.jar with Service Accounts. 您仍然可以将旧库AppsForYourDomainClient.jar与服务帐户一起使用。 You need to override the method were the user/password are used and set your GoogleCredential: 您需要覆盖使用用户名/密码的方法,并设置您的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);
Google's own library is here: https://github.com/google/google-oauth-java-client , with Maven details if y are using it. Google自己的库在这里: https : //github.com/google/google-oauth-java-client ,如果您正在使用Maven详细信息。
Documentation, with examples, starts here: https://developers.google.com/api-client-library/java/google-oauth-java-client/ 文档和示例从此处开始: https : //developers.google.com/api-client-library/java/google-oauth-java-client/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.