+1 vote

Hi,

We are using 2Legged OAuth with a Google Service Account to request access tokens on behalf of a Google domain user. The AccessToken is valid for 1 hour. After it expires, we go back out and request a new AccessToken in the same way (no refresh tokens with 2L0).

This process works for about 2 hours, where we are reading probably 100 UIDs and getting back the MessageInfo for each UID. At that point, I get an ALERT Invalid credentials error (see below). This is occurring before the token is set to expire. Requesting a new access token and connecting via IMAP continues to give the [ALERT] Invalid Credentials error.

Limilabs.Client.ServerException: [ALERT] Invalid credentials (Failure) ---{"status":"400","schemes":"Bearer","scope":"https://mail.google.com/"}

Internally in the IMAP client - what response codes or exceptions from Google could be causing this issue?

Thank you,

Mike

by (450 points)
retagged by

1 Answer

0 votes
 
Best answer
  1. Consider using OAuth 2.0: https://www.limilabs.com/blog/oauth2-gmail-imap-service-account

  2. If the server returns "Invalid credentials" error, there is nothing you can do. You must obtain another token.

by (297k points)
selected by
...