admin管理员组

文章数量:1122846

We have build an OAuth app which takes basic scope and gmail readonly scope .readonly. Application subscribes the pub/sub and on receiving hit from Gmail, we call API to fetch list of mails after particular historyId ().

The above setup is working for most of the GSuite account. For one of the GSuite account, the users are able to connect their account via OAuth and subscribe to the pub/sub via API () and receiving hits on the webhook URL as well. But while calling above mail API(just after connecting the account, so the access token is valid only)to fetch list of mails, Gmail is returning 401 error with message Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See .

Can someone explain what can be the possible reason for above API fails.

I checked the Gsuite settings and verified that the OAuth app is marked as Trusted for the Organizational unit in which users are trying to connect.

The GSuite account which is facing issue is of Google Workspace for Education editions

Update: After trying few more times, the token is getting invalidated within few minutes (around 4-5 min) after connecting the token. If the user make any API call within 5 min, it is working fine but after 5 min the token is getting invalidated.

本文标签: gmailGSuite oauth token getting unauthenticated for calling mail APIStack Overflow