【问题标题】:Google API - Account disabled and then re-enabled, now "Not Authorized to access this resource/api"Google API - 帐户被禁用然后重新启用,现在“无权访问此资源/api”
【发布时间】:2017-04-21 11:06:58
【问题描述】:

几年来,我们的应用程序使用 OAuth 2 安全性(服务帐户和 p12 密钥)愉快地运行,通过目录 API 更新 Google 目录信息(即电话号码、姓名等)。该帐户(即 user@domain.com)被错误地禁用,因此更新停止工作。该帐户已重新启用(我已通过登录验证了这一点),但应用程序现在在尝试执行更新时出现 403 - “未授权访问此资源/api”错误。

我已经在 Google API 控制台中完成了我能想到的所有事情,并且服务帐户似乎一切正常。谁能想到一些明显的事情,我应该检查一下以找出问题所在?

如果有帮助,用于构建身份验证的 Java 代码是:

HttpTransport httpTransport = new NetHttpTransport();
JsonFactory jsonFactory = new JacksonFactory();

GoogleCredential credential = new GoogleCredential.Builder()
  .setTransport(httpTransport)
  .setJsonFactory(jsonFactory)
  .setServiceAccountId(googleServiceAttributes.getServiceAccountId())
  .setServiceAccountScopes(serviceAccountScopes)
  .setServiceAccountPrivateKey(googleServiceAttributes.getPrivateKey())
  .setServiceAccountUser(googleServiceAttributes.getServiceAccountUsername())
  .build();

(使用的帐户范围是“https://www.googleapis.com/auth/admin.directory.user”,用于目录 API 的客户端 jar 是 google-api-services-admin-directory_v1-rev22-1.16.0-rc.jar,API jar 是google-api-client-1.16.0-rc.jar)

谢谢...

【问题讨论】:

    标签: google-api


    【解决方案1】:

    尝试通过“Try It”使用相同的 API。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-15
      • 2014-12-12
      • 2020-06-01
      • 2018-08-01
      • 2021-05-19
      • 1970-01-01
      • 1970-01-01
      • 2018-05-16
      相关资源
      最近更新 更多