|
| 1 | +# Auth |
| 2 | + |
| 3 | +## Endpoints |
| 4 | + |
| 5 | +| Route | Method | Description | |
| 6 | +|-------|--------|-------------| |
| 7 | +| [/auth/google/login](#get-authgooglelogin) | GET | Initiates the Google OAuth authentication | |
| 8 | +| [/auth/google/callback](#get-authgooglecallback) | GET | Handles the callback from Google after the user authenticates | |
| 9 | + |
| 10 | +## GET /auth/google/login |
| 11 | + |
| 12 | +Initiates the Google OAuth authentication process by redirecting the user to Google's consent screen. |
| 13 | + |
| 14 | +- **Params** |
| 15 | + None |
| 16 | + |
| 17 | +- **Query** |
| 18 | + - Optional: `redirectURL=[string]` (The URL to redirect the user to after authentication is successful. It should be a valid URL.) |
| 19 | + |
| 20 | +### Response |
| 21 | + |
| 22 | +- **Success Response**: |
| 23 | + - **Code:** 302 |
| 24 | + |
| 25 | + - **Content:** Redirects to Google's OAuth 2.0 consent screen for user authentication. |
| 26 | + |
| 27 | + ```text |
| 28 | + Location: https://accounts.google.com/o/oauth2/v2/auth?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=email&state={redirectURL} |
| 29 | + ``` |
| 30 | +
|
| 31 | +- **Error Response:** |
| 32 | + - **Code:** 401 |
| 33 | + - **Content:** |
| 34 | +
|
| 35 | + ```json |
| 36 | + { |
| 37 | + "statusCode": 401, |
| 38 | + "error": "Unauthorized", |
| 39 | + "message": "User cannot be authenticated" |
| 40 | + } |
| 41 | + ``` |
| 42 | + - **Code:** 500 |
| 43 | +
|
| 44 | + - **Content:** |
| 45 | +
|
| 46 | + ```json |
| 47 | + { |
| 48 | + "statusCode": 500, |
| 49 | + "error": "Internal Server Error", |
| 50 | + "message": "An internal server error occurred" |
| 51 | + } |
| 52 | + ``` |
| 53 | +
|
| 54 | +## GET /auth/google/callback |
| 55 | +
|
| 56 | +Handles the callback from Google after the user authenticates, exchanges the authorization code for an access token, and completes the user login process. |
| 57 | +
|
| 58 | +- **Params** |
| 59 | + None |
| 60 | +
|
| 61 | +- **Query** |
| 62 | + - Required: `code=[string]` (The authorization code returned by Google after the user grants consent.) |
| 63 | + - Required: `state=[string]` (The state parameter returned by Google, used to verify the request’s legitimacy and ensure security.) |
| 64 | +
|
| 65 | +### Response |
| 66 | +
|
| 67 | +- **Success Response**: |
| 68 | + - **Code**: 302 |
| 69 | + - **Content**: Redirects to the specified redirectURL or https://my.realdevsquad.com/new-signup if user details are incomplete. |
| 70 | +
|
| 71 | + ``` |
| 72 | + Location: {redirectURL} |
| 73 | + ``` |
| 74 | + - **Cookie**: A secure JWT authentication token (rds-session) is set as a cookie to maintain the user's session. |
| 75 | + ``` |
| 76 | + Set-Cookie: rds-session=<jwt_token>; Domain={realdevsqual.com}; Expires={expirationTime}; HttpOnly; Secure; SameSite=Lax |
| 77 | + ``` |
| 78 | +
|
| 79 | +- **Error Response:** |
| 80 | + - **Code:** 401 |
| 81 | + - **Content:** |
| 82 | +
|
| 83 | + ```json |
| 84 | + { |
| 85 | + "statusCode": 401, |
| 86 | + "error": "Unauthorized", |
| 87 | + "message": "User cannot be authenticated" |
| 88 | + } |
| 89 | + ``` |
| 90 | + - **Code:** 500 |
| 91 | +
|
| 92 | + - **Content:** |
| 93 | +
|
| 94 | + ```json |
| 95 | + { |
| 96 | + "statusCode": 500, |
| 97 | + "error": "Internal Server Error", |
| 98 | + "message": "An internal server error occurred" |
| 99 | + } |
| 100 | + ``` |
0 commit comments