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
- Google - Google OAuth 2.0
- Auth0 - Auth0 Universal Login
- GitHub - GitHub OAuth Apps
- Custom Provider - Build your own
Password Authentication
- Password - Username/password with email verification
Development
- Mock Provider - Development and testing
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:
- Module Configuration - Applied globally to all requests for that provider:
typescript
// nuxt.config.ts
export default defineNuxtConfig({
nuxtAegis: {
providers: {
google: {
authorizationParams: {
access_type: 'offline',
},
},
},
},
})- 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
- Learn how to configure Google
- Set up Auth0
- Configure Password Authentication
- Use the Mock Provider for testing
- Build a Custom Provider