Search code examples
tokengoogle-oauth

Why Google OAuth2 needs client secret and refresh token to get access token?


After reading the Google OAuth2 documents, I have downloaded the application_default_credentials.json and used this to get access token(bearer token).

I'm not sure if this's the standard of OAuth2. Some documents show that we need refresh token and client credential to get access token, but why not just refresh token? If I have client credential, does that mean I can get access token directly?


Solution

  • Yes, it is part of the OAuth2 specification that you must send the client credentials along with the refresh token. From RFC 6749, section 6:

    Because refresh tokens are typically long-lasting credentials used to request additional access tokens, the refresh token is bound to the client to which it was issued. If the client type is confidential or the client was issued client credentials (or assigned other authentication requirements), the client MUST authenticate with the authorization server.