Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nuxt-alt/auth/llms.txt

Use this file to discover all available pages before exploring further.

The Google provider configures @nuxt-alt/auth to authenticate users through Google’s OAuth2 service. It uses the oauth2 scheme and wires up Google’s authorization and userinfo endpoints automatically. The userinfo endpoint targets the Google OAuth2 v3 API, which returns standard OpenID Connect claims such as sub, name, picture, and email. Your clientId and clientSecret come from a Google Cloud project with the OAuth2 API enabled.

Required Options

OptionTypeDescription
clientIdstringThe OAuth 2.0 Client ID from Google Cloud Console
clientSecretstringThe OAuth 2.0 Client Secret from Google Cloud Console

Configuration

export default defineNuxtConfig({
  auth: {
    strategies: {
      google: {
        clientId: 'YOUR_CLIENT_ID',
        clientSecret: 'YOUR_CLIENT_SECRET',
        // Optional: override the default scopes
        scope: ['openid', 'profile', 'email'],
      },
    },
  },
})

Auto-Configured Defaults

When the strategy name is google, the provider automatically sets the following values. Any property you specify in your own config takes precedence.
PropertyAuto-Configured Value
scheme'oauth2'
endpoints.authorizationhttps://accounts.google.com/o/oauth2/v2/auth
endpoints.userInfohttps://www.googleapis.com/oauth2/v3/userinfo
scope['openid', 'profile', 'email']
token.property'access_token'
token.type'Bearer'
token.name'Authorization'
idToken.property'id_token'
refreshToken.property'refresh_token'
responseType'token'
clientSecretTransport'body'
To receive a refresh token from Google, add access_type: 'offline' and prompt: 'consent' to the authorization request. You can pass these as additional query parameters via the accessType option or by extending the authorization endpoint URL.

Logging In

Trigger the Google OAuth redirect from any component or composable:
const auth = useAuth()
await auth.loginWith('google')
The user is redirected to Google’s consent screen. After granting access, Google redirects back to your application’s callback route where @nuxt-alt/auth exchanges the token and fetches the user profile.
In the Google Cloud Console, navigate to APIs & Services → Credentials and add your application’s callback URL to the Authorized redirect URIs list for your OAuth 2.0 Client ID. The default callback route is /login. You must also configure the OAuth consent screen and ensure the email, profile, and openid scopes are listed as non-sensitive scopes.

Build docs developers (and LLMs) love