Authentication on google: OAuth2 keeps returning 'invalid_grant'

后端 未结 6 1446
[愿得一人]
[愿得一人] 2020-11-28 15:23

I started to configure google calendar on my new application. I almost made an exact copy of the authentication code displayed at google developers ( https://developers.goog

相关标签:
6条回答
  • 2020-11-28 15:29
    1. Go to security.google.com
    2. Revoke access
    3. visit the authentication url again
    4. you will now get a new refreshtoken
    0 讨论(0)
  • 2020-11-28 15:32

    You should reuse the access token you get after the first successful authentication. You will get an invalid_grant error if your previous token has not expired yet. Cache it somewhere so you can reuse it.

    0 讨论(0)
  • 2020-11-28 15:38

    I was having a similar problem caused by the time on my server being incorrect. Make sure your system clock is synchronised.

    0 讨论(0)
  • 2020-11-28 15:38

    I had a similar issue. The problem with "invalid_grant" is that it's basically a placeholder for any error that occurs in relation to the token. I found this article to be really helpful.

    0 讨论(0)
  • 2020-11-28 15:40

    You'll also receive this error if you mistakenly try to authenticate your ID Token, rather than your Access Token.

    So don't be like me - Make sure you pass the correct token into your code!

    0 讨论(0)
  • 2020-11-28 15:44

    Go to your Google API Console ( https://code.google.com/apis/console/ ) and revoke your Client Secret under Client ID for installed applications.

    Be sure to also update your code with the new Client Secret

    0 讨论(0)
提交回复
热议问题