Skip to content

Commit

Permalink
Merge pull request #210 from listiclehub1/api-contract-github-auth
Browse files Browse the repository at this point in the history
Added api contract for github auth
  • Loading branch information
Achintya-Chatterjee authored Jan 2, 2025
2 parents 490ad71 + dab263f commit d77c8ba
Showing 1 changed file with 94 additions and 0 deletions.
94 changes: 94 additions & 0 deletions auth/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
|-------|--------|-------------|
| [/auth/google/login](#get-authgooglelogin) | GET | Initiates the Google OAuth authentication |
| [/auth/google/callback](#get-authgooglecallback) | GET | Handles the callback from Google after the user authenticates |
| [/auth/github/login](#get-authgithublogin) | GET | Initiates the GitHub OAuth authentication |
| [/auth/github/callback](#get-authgithubcallback) | GET | Handles the callback from GitHub after the user authenticates |

## GET /auth/google/login

Expand All @@ -15,6 +17,7 @@ Initiates the Google OAuth authentication process by redirecting the user to Goo
None

- **Query**
- Required: `dev=[boolean]` (Must be set to true for this feature to work.)
- Optional: `redirectURL=[string]` (The URL to redirect the user to after authentication is successful. It should be a valid URL.)

### Response
Expand Down Expand Up @@ -64,6 +67,97 @@ Handles the callback from Google after the user authenticates, exchanges the aut
### Response
- **Success Response**:
- **Code**: 302
- **Content**: Redirects to the specified redirectURL or https://my.realdevsquad.com/new-signup if user details are incomplete.
```
Location: {redirectURL}
```
- **Cookie**: A secure JWT authentication token (rds-session) is set as a cookie to maintain the user's session.
```
Set-Cookie: rds-session=<jwt_token>; Domain={realdevsqual.com}; Expires={expirationTime}; HttpOnly; Secure; SameSite=Lax
```
- **Error Response:**
- **Code:** 401
- **Content:**
```json
{
"statusCode": 401,
"error": "Unauthorized",
"message": "User cannot be authenticated"
}
```
- **Code:** 500
- **Content:**
```json
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal server error occurred"
}
```
## GET /auth/github/login
Initiates the GitHub OAuth authentication process by redirecting the user to GitHub's consent screen.
- **Params**
None
- **Query**
- Optional: `redirectURL=[string]` (The URL to redirect the user to after authentication is successful. It should be a valid URL.)
### Response
- **Success Response**:
- **Code:** 302
- **Content:** Redirects to GitHub's OAuth 2.0 consent screen for user authentication.
```text
Location: Location: https://github.com/login/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=user:email&state={state}
```
- **Error Response:**
- **Code:** 401
- **Content:**
```json
{
"statusCode": 401,
"error": "Unauthorized",
"message": "User cannot be authenticated"
}
```
- **Code:** 500
- **Content:**
```json
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal server error occurred"
}
```
## GET /auth/github/callback
Handles the callback from GitHub after the user authenticates, exchanges the authorization code for an access token, and completes the user login process.
- **Params**
None
- **Query**
- Required: `code=[string]` (The authorization code returned by GitHub after the user grants consent.)
- Required: `state=[string]` (The state parameter returned by GitHub, used to verify the request’s legitimacy and ensure security.)
### Response
- **Success Response**:
- **Code**: 302
- **Content**: Redirects to the specified redirectURL or https://my.realdevsquad.com/new-signup if user details are incomplete.
Expand Down

0 comments on commit d77c8ba

Please sign in to comment.