Endpoint: GET /auth/google
Description: Initiate Google OAuth authentication flow.
Response: Redirects to Google OAuth consent screen.
9. Google OAuth Callback
Endpoint: GET /auth/google/callback
Description: Handle Google OAuth callback and authenticate user.
Success Response (200):
{
"success": true,
"message": "Authentication successful",
"user": {
"id": "507f1f77bcf86cd799439011",
"name": "John Doe",
"email": "john@example.com"
},
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Cookies Set:
-
accessToken
(HttpOnly, Secure, SameSite=None, 1 hour expiry) -
refreshToken
(HttpOnly, Secure, SameSite=None, 30 days expiry)
Error Response:
401 Unauthorized:
{
"success": false,
"message": "Authentication failed"
}