Back to Supabase

Google Auth Fails For Some Users XcFXEu

apps/docs/content/troubleshooting/google-auth-fails-for-some-users-XcFXEu.mdx

1.26.04985 B
Original Source

Google Auth fails for some users

If you start facing either of these errors:

error=server_error&error_description=Error+getting+user+email+from+external+provider

Missing required authentication credential.

Expected OAuth 2 access token, login cookie or other valid authentication credential.

See https://developers.google.com/identity/sign-in/web/devconsole-project.\",\n \"status\": \"UNAUTHENTICATED\"

 }
 "level":"error","method":"GET","msg":"500: Error getting user email from external provider","path":"/callback","referer":"https://accounts.google.com/","remote_addr":"x.x.X.x","time":"2023-06-06T21:46:11Z","timestamp":"2023-06-06T21:46:11Z"}

It is happening because some Google Suite requires the explicit request of email Auth Scopes: https://www.googleapis.com/auth/userinfo.email

js
const { data, error } = await supabase.auth.signInWithOAuth({
  provider: 'google'
  options: {
    scopes: 'https://www.googleapis.com/auth/userinfo.email'
  }
})