You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Configuration options for Google OAuth authentication:
157
+
158
+
```typescript
159
+
interfaceGoogleOAuthOptions {
160
+
/**
161
+
* Google OAuth client ID from Google Cloud Console
162
+
*/
163
+
clientId:string
164
+
165
+
/**
166
+
* Google OAuth client secret from Google Cloud Console
167
+
*/
168
+
clientSecret:string
169
+
170
+
/**
171
+
* Callback URL for Google OAuth (must match what's configured in Google Cloud Console)
172
+
* @default'/api/nuxt-users/auth/google/callback'
173
+
*/
174
+
callbackUrl?:string
175
+
176
+
/**
177
+
* Redirect URL after successful authentication
178
+
* @default'/'
179
+
*/
180
+
successRedirect?:string
181
+
182
+
/**
183
+
* Redirect URL after failed authentication
184
+
* @default'/login?error=oauth_failed'
185
+
*/
186
+
errorRedirect?:string
187
+
188
+
/**
189
+
* Google OAuth scopes to request
190
+
* @default['openid', 'profile', 'email']
191
+
*/
192
+
scopes?:string[]
193
+
194
+
/**
195
+
* Allow automatic user registration when logging in with Google for the first time
196
+
* If false, only existing users with matching email can log in with Google
197
+
* @defaultfalse
198
+
*/
199
+
allowAutoRegistration?:boolean
200
+
}
201
+
```
202
+
203
+
**Example usage:**
204
+
205
+
```typescript
206
+
// nuxt.config.ts
207
+
exportdefaultdefineNuxtConfig({
208
+
modules: ['nuxt-users'],
209
+
nuxtUsers: {
210
+
auth: {
211
+
google: {
212
+
clientId: process.env.GOOGLE_CLIENT_ID!,
213
+
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
214
+
allowAutoRegistration: false, // Only existing users can log in
215
+
successRedirect: '/dashboard',
216
+
errorRedirect: '/login?error=oauth_failed'
217
+
}
218
+
}
219
+
}
220
+
})
221
+
```
222
+
223
+
::: tip
224
+
By default, `allowAutoRegistration` is `false` for security. This means only users with existing accounts (by email) can log in with Google. Set it to `true` to allow public registration via Google OAuth.
225
+
:::
226
+
227
+
::: warning
228
+
When `allowAutoRegistration: false`, new Google users will be redirected to `errorRedirect` with the error code `user_not_registered`.
229
+
:::
230
+
146
231
### ModuleOptions
147
232
148
233
Fully resolved module options (after merging with defaults):
0 commit comments