File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ # Google OAuth Configuration
2+ # Get these from https://console.cloud.google.com/
3+ # 1. Create a new project or select existing
4+ # 2. Enable Google+ API or People API
5+ # 3. Go to Credentials > Create Credentials > OAuth 2.0 Client ID
6+ # 4. Set callback URL to: http://localhost:3000/api/nuxt-users/auth/google/callback
7+
8+ GOOGLE_CLIENT_ID = your_google_client_id_here
9+ GOOGLE_CLIENT_SECRET = your_google_client_secret_here
10+
11+ # Example values for development:
12+ # GOOGLE_CLIENT_ID=123456789-abcdefghijklmnopqrstuvwxyz.apps.googleusercontent.com
13+ # GOOGLE_CLIENT_SECRET=GOCSPX-abcdefghijklmnopqrstuvwxyz
Original file line number Diff line number Diff line change @@ -15,6 +15,12 @@ export default defineNuxtConfig({
1515 /* permissions: {
1616 admin: ['*'],
1717 }, */
18+ google : {
19+ clientId : process . env . GOOGLE_CLIENT_ID || 'demo-client-id' ,
20+ clientSecret : process . env . GOOGLE_CLIENT_SECRET || 'demo-client-secret' ,
21+ successRedirect : '/' ,
22+ errorRedirect : '/login?error=oauth_failed'
23+ }
1824 } ,
1925 passwordValidation : {
2026 minLength : 3 ,
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ const handleSubmit = (data) => {
1919 // The login composable will now handle the rememberMe flag automatically
2020 // when the server responds with user data after successful authentication
2121}
22+
23+ const handleGoogleLogin = () => {
24+ console .log (' [Nuxt Users] Starting Google OAuth flow' )
25+ }
2226 </script >
2327
2428<template >
@@ -40,6 +44,20 @@ const handleSubmit = (data) => {
4044 @error =" handleError"
4145 @submit =" handleSubmit"
4246 />
47+
48+ <div class =" oauth-divider" >
49+ <span >or</span >
50+ </div >
51+
52+ <div class =" oauth-section" >
53+ <h3 >OAuth Login</h3 >
54+ <p >Click below to test Google OAuth (requires valid credentials in .env)</p >
55+ <NUsersGoogleLoginButton
56+ @click =" handleGoogleLogin"
57+ button-text =" Continue with Google"
58+ class =" google-btn"
59+ />
60+ </div >
4361 </div >
4462</template >
4563
@@ -90,6 +108,50 @@ nav a {
90108 text-align : center ;
91109}
92110
111+ .oauth-divider {
112+ display : flex ;
113+ align-items : center ;
114+ text-align : center ;
115+ margin : 2rem 0 ;
116+ }
117+
118+ .oauth-divider ::before ,
119+ .oauth-divider ::after {
120+ content : ' ' ;
121+ flex : 1 ;
122+ height : 1px ;
123+ background : var (--nu-color-border );
124+ }
125+
126+ .oauth-divider span {
127+ padding : 0 1rem ;
128+ color : var (--nu-color-gray-500 );
129+ font-size : 0.875rem ;
130+ background : var (--nu-color-bg );
131+ }
132+
133+ .oauth-section {
134+ text-align : center ;
135+ margin-top : 2rem ;
136+ }
137+
138+ .oauth-section h3 {
139+ color : var (--nu-color-gray-700 );
140+ margin-bottom : 0.5rem ;
141+ font-size : 1.25rem ;
142+ font-weight : 600 ;
143+ }
144+
145+ .oauth-section p {
146+ color : var (--nu-color-gray-500 );
147+ margin-bottom : 1rem ;
148+ font-size : 0.875rem ;
149+ }
150+
151+ .google-btn {
152+ margin : 0 auto ;
153+ }
154+
93155/* Responsive design */
94156@media (max-width : 48rem ) {
95157 .demo-container {
You can’t perform that action at this time.
0 commit comments