π Overview
Implement Google OAuth authentication in LogiQuest to allow users to sign in with their Google accounts. This feature should leverage Passport.js and work seamlessly within the existing authentication flow.
π οΈ Tasks
-
Add Google OAuth Strategy
- Implement a Google OAuth strategy using Passport.js
- Create a GoogleStrategy provider
- Configure authentication using environment variables (ensure documentation is updated)
-
Create Authentication Controller Endpoints
- Add an endpoint to initiate Google authentication
- Create a callback endpoint to handle Google's response
- Implement user profile creation for new Google users
-
Update User Entity
- Add a
googleId field
- Add a
provider field (values: local/google)
- Ensure proper updates to the database schema
-
JWT Generation for Google Auth
- Generate JWT tokens after successful Google authentication
- Ensure proper user data is included in the tokens
-
HTTPyac Test Files
- Include HTTPyac test files to demonstrate the working implementation
### Initiate Google Auth (this will redirect to Google)
GET http://localhost:3000/auth/google
### Manually test the callback URL after authentication
GET http://localhost:3000/auth/google/callback?code=EXAMPLE_CODE
### Verify that the JWT token works by accessing a protected endpoint
GET http://localhost:3000/auth/profile
Authorization: Bearer {{google.response.body.access_token}}
π¨ Technical & Setup Considerations
- Use
@nestjs/passport and passport-google-oauth20 packages
- Use environment variables for Google OAuth credentials (Client ID/Secret)
- IMPORTANT: Use
npm ci instead of npm install when setting up the project to avoid dependency issues
β
Acceptance Criteria
- Users can initiate authentication with Google
- Google authentication flow completes successfully
- New users are created on first Google login
- Existing users are properly linked with Google accounts
- JWT tokens are issued after successful authentication
- Error handling for failed authentication attempts
- Environment variables are documented for Google OAuth credentials
π References
Let's ensure we follow the dependency guidelines and use the proper setup commands π
π Overview
Implement Google OAuth authentication in LogiQuest to allow users to sign in with their Google accounts. This feature should leverage Passport.js and work seamlessly within the existing authentication flow.
π οΈ Tasks
Add Google OAuth Strategy
Create Authentication Controller Endpoints
Update User Entity
googleIdfieldproviderfield (values: local/google)JWT Generation for Google Auth
HTTPyac Test Files
π¨ Technical & Setup Considerations
@nestjs/passportandpassport-google-oauth20packagesnpm ciinstead ofnpm installwhen setting up the project to avoid dependency issuesβ Acceptance Criteria
π References
Let's ensure we follow the dependency guidelines and use the proper setup commands π