Problems with Google OAuth2 on iOS - "invalid_grant" Error

I have problems with Google OAuth2 on iOS; I get the error "invalid_grant". I am doing the following steps:

  • I created a project and account (iOS application) Google Console;
  • I requested the code:
  • I requested an access token (works well);
  • 10 minutes before the access token expires, I request an update token.

The problem is intermittent. Sometimes the refresh request (refresh_token) returns "invalid_grant", and therefore the access_token becomes invalid and my application just stops.

If you force the user login to create a new access_token and refresh_token does not work. I need to revoke account permissions and try again. I need access to IMAP and SMTP Gmail. If I checked access_token ( https://www.googleapis.com/oauth2/v1/tokeninfo ), it is active and valid, but IMAP and SMTP refuse access.

I really think about returning a username and password. The service is very unstable because it does not have the same reaction. I am sure that I do not violate any restrictions, and the message "invalid_grant" at least does not fit.

Please, any Google employee, HELP ME!

Thank.

+3
source share
1 answer

. IMAP, invalid_grant auth. , :

authentication.refreshToken = savedRefreshToken;
authentication.accessToken = savedAccessToken;
authentication.additionalTokenRequestParameters = @{@"access_type":@"offline"};

, , . - Google, , . .

0

All Articles