【问题标题】:401 Unauthorized Error when trying to read corporative emails in Gsuite from a Gmail account using Account Service尝试使用帐户服务从 Gmail 帐户读取 Gsuite 中的公司电子邮件时出现 401 未经授权的错误
【发布时间】:2018-05-26 12:54:31
【问题描述】:

我在公司 Gmail 帐户(尤其是 Gsuite Gmail 帐户)中阅读电子邮件时遇到问题。

我已经按照以下步骤操作了:

很遗憾,我收到此错误:com.google.api.client.auth.oauth2.TokenResponseException: 401 Unauthorized

非常感谢您提供的任何帮助。

问候

【问题讨论】:

  • 如果您将服务帐户的电子邮件用于变量 ACCOUNT_EMAIL 而不是您自己的电子邮件,会发生什么情况?
  • @noogui maven 依赖项的版本有问题。我发布了具有正确依赖关系的答案。

标签: api gmail key gmail-api google-workspace


【解决方案1】:

maven 依赖有问题。

使用这些依赖关系解决了这个问题。

<dependency>
    <groupId>com.google.api-client</groupId>
    <artifactId>google-api-client</artifactId>
    <version>1.23.0</version>
</dependency>

<dependency>
    <groupId>com.google.oauth-client</groupId>
    <artifactId>google-oauth-client-jetty</artifactId>
    <version>1.23.0</version>
</dependency>

<dependency>
    <groupId>com.google.apis</groupId>
    <artifactId>google-api-services-gmail</artifactId>
    <version>v1-rev73-1.23.0</version>
</dependency>

【讨论】:

    猜你喜欢
    • 2020-01-06
    • 2018-10-20
    • 2020-11-01
    • 2012-05-20
    • 1970-01-01
    • 2021-01-01
    • 2020-08-03
    • 2019-05-28
    • 2018-02-19
    相关资源
    最近更新 更多