Skip to content

OAuth Providers ​

Nuxt Aegis supports multiple OAuth providers out of the box, plus password-based authentication, making it easy to add authentication to your application.

Supported Providers ​

OAuth 2.0 Providers ​

Password Authentication ​

  • Password - Username/password with email verification

Development ​

Authorization Parameters ​

All OAuth providers support custom authorization parameters via the authorizationParams configuration option. These parameters are appended to the authorization URL when redirecting users to the OAuth provider.

Security Note

Critical OAuth parameters (client_id, redirect_uri, code, grant_type) are protected and cannot be overridden. If you attempt to override these, a warning will be logged and the parameters will be ignored.

Common Use Cases ​

typescript
authorizationParams: {
  access_type: 'offline',  // Get refresh token
  prompt: 'consent',       // Force consent screen
}
typescript
authorizationParams: {
  hd: 'example.com',  // Only allow users from example.com
}
typescript
authorizationParams: {
  prompt: 'login',         // Always show login screen
  screen_hint: 'signup',   // Show signup form
}
typescript
authorizationParams: {
  allow_signup: 'true',  // Allow new account creation
}

Configuration Locations ​

Authorization parameters can be set in two places:

  1. Module Configuration - Applied globally to all requests for that provider:
typescript
// nuxt.config.ts
export default defineNuxtConfig({
  nuxtAegis: {
    providers: {
      google: {
        authorizationParams: {
          access_type: 'offline',
        },
      },
    },
  },
})
  1. Event Handler - Applied only to requests handled by that specific route:
typescript
// server/routes/auth/google.get.ts
export default defineOAuthGoogleEventHandler({
  config: {
    authorizationParams: {
      prompt: 'consent',
    },
  },
})

Precedence

Event handler parameters override module configuration parameters if both are defined.

Next Steps ​

Released under the MIT License.