pilcrowonpaper / arctic

OAuth 2.0 clients for popular providers
MIT License
1.11k stars 65 forks source link

Google OAuth doesn't return refresh token #125

Closed jerriclynsjohn closed 6 months ago

jerriclynsjohn commented 6 months ago

I have the following code

const googleScopes = [
    'openid',
    'email', 
    'profile', 
    // Gmail API scopes
    'https://www.googleapis.com/auth/gmail.readonly',
    // People API scopes
    'https://www.googleapis.com/auth/contacts.readonly'
  ];

  const state = generateState();
  const codeVerifier = generateCodeVerifier();

  const url = await google.createAuthorizationURL(state, codeVerifier, {
    scopes: googleScopes
  });

and to get the token

const tokens: GoogleTokens = await google.validateAuthorizationCode(code, storedCodeVerifier);

tokens.refreshToken is always null, even if I'm authenticating the email for the first time.

pilcrowonpaper commented 6 months ago

Please read the docs

https://arctic.js.org/providers/google#get-refresh-token