【问题标题】:Google Email Settings api using OAuth 2.0 service account in java在 Java 中使用 OAuth 2.0 服务帐户的 Google 电子邮件设置 api
【发布时间】:2015-04-03 23:55:07
【问题描述】:

我想使用 Java 中的 OAuth2.0 服务帐户身份验证方法使用 Google 电子邮件设置 api,但是我无法从 Google 找到任何有用的客户端类或有关如何执行此操作的示例示例。我查看了对用户或组相关操作非常有用的 Directory api。电子邮件设置 api 有没有等价物?

【问题讨论】:

    标签: java google-admin-sdk service-accounts google-email-settings-api google-oauth


    【解决方案1】:

    您仍然可以将旧库 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);
    

    【讨论】:

      【解决方案2】:

      Google 自己的库在这里:https://github.com/google/google-oauth-java-client,如果你正在使用它,还有 Maven 详细信息。

      带有示例的文档从这里开始:https://developers.google.com/api-client-library/java/google-oauth-java-client/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-06-22
        • 2014-04-30
        • 2023-03-09
        • 1970-01-01
        • 1970-01-01
        • 2021-09-29
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多