电子邮件设置API-ClientLogin [英] Email Settings API - ClientLogin

查看:208
本文介绍了电子邮件设置API-ClientLogin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用EMAIL设置API和ClientLogin进行身份验证. EMAIL设置API仍在GDATA库中.使用GDATA库,我们可以开始使用OAuth 2.0吗? (我们正在使用appsforyourdomain客户端库来使用EMAIL设置API)还是可以继续使用ClientLogin?根据该帖子,ClientLogin将于2015年4月20日退休.请为我提供正确的方法. GDATA API:1.46.0. EMAIL设置API仅用于为用户禁用网络剪辑.

We are using EMAIL Settings API and ClientLogin for Authentication. EMAIL Settings API is still on GDATA Libraries. Using GDATA libraries can we start using OAuth 2.0 ? (we are using the appsforyourdomain client library to use EMAIL Settings API) Or can we continue using ClientLogin ? Based on the post looks like ClientLogin is going to retire by April 20, 2015. Please guide me the right approach. GDATA API : 1.46.0. EMAIL Settings API is used only for disabling the webclips for the user.

推荐答案

我们正在使用GDATA API 1.46.0,它不支持OAuth 2.0.支持已添加到1.47.0版本中.请参阅下面的发行说明.使用新的库后,我可以实现OAuth 2.0. 在appsforyourdomain客户端库中使用了GmailSettingsService类,并注释掉了ClientLogin流,并为OAuth2.0添加了新流.使用GoogleCredential对象创建OAuth2.0凭据对象.

We were using GDATA API 1.46.0 and it does not support OAuth 2.0 . Support was added in 1.47.0 version. See the release note below. After using the new Libraries I was able to implement OAuth 2.0. Used GmailSettingsService class inside the appsforyourdomain client library and commented out the ClientLogin flow and added new flow for OAuth2.0. Use GoogleCredential Object to create the OAuth2.0 credential object.

//  Client Login
//  this.setUserCredentials(username + "@" + domain, password);

//  OAuth 2.0
this.setOAuth2Credentials(initCredential());

public static GoogleCredential initCredential() throws GeneralSecurityException, IOException {
      httpTransport = GoogleNetHttpTransport.newTrustedTransport();

    List<String> scopes = Arrays.asList("https://apps-apis.google.com/a/feeds/emailsettings/2.0/");

    credential = new GoogleCredential.Builder()
        .setTransport(httpTransport)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(SERVICE_ACCOUNT_EMAIL)
        .setServiceAccountScopes(scopes)
        .setServiceAccountPrivateKeyFromP12File(new File(SERVICE_ACCOUNT_PKCS12_FILE_PATH))
        .setServiceAccountUser(DOMAIN_ADMIN_API_USER)
        .build();  
    return credential;
  }

v1.47.0的注意事项

o利用Java的Google OAuth客户端添加OAuth 2.0支持( http://code.google.com/p/google-oauth-java-client/).

这篇关于电子邮件设置API-ClientLogin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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