I have created credentials on google developer console:
The oauth client is in test mode (not verified yet), but added some test emails.
I could successfully retrieve an access token with authorization code grant flow, using an authorization url that looks like this (client id, redirect_uri changed):
Most importantly:
The token response looks like this:
{
"access_token": "***",
"expires_in": 3108,
"scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/blogger openid",
"token_type": "Bearer",
"id_token": "***"
}
Why am I not getting a refresh token from the token endpoint? Even though access_type=offline was specified. I think refresh_token is only provided for the first login, so I I tried to login from incognito mode, but it did not help.
Is it because the oauth client is in test mode? I tried to find information about restrictions of test mode oauth clients, and could not find anything about refresh tokens.
I believe you'll need
access_type=offline&prompt=consent
like in this answer
As OP commented
In golang goth library, this corresponds to: oauth2.AuthCodeURL(state, oauth2.AccessTypeOffline, oauth2.ApprovalForce). The name oauth2.ApprovalForce is a bit misleading, it actually adds prompt=consent.