Skip to content

Commit 38078fb

Browse files
committed
Added api contract for github auth
1 parent 82ca74f commit 38078fb

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

auth/README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
|-------|--------|-------------|
77
| [/auth/google/login](#get-authgooglelogin) | GET | Initiates the Google OAuth authentication |
88
| [/auth/google/callback](#get-authgooglecallback) | GET | Handles the callback from Google after the user authenticates |
9+
| [/auth/github/login](#get-authgithublogin) | GET | Initiates the GitHub OAuth authentication |
10+
| [/auth/github/callback](#get-authgithubcallback) | GET | Handles the callback from GitHub after the user authenticates |
911

1012
## GET /auth/google/login
1113

@@ -64,6 +66,97 @@ Handles the callback from Google after the user authenticates, exchanges the aut
6466
6567
### Response
6668
69+
- **Success Response**:
70+
- **Code**: 302
71+
- **Content**: Redirects to the specified redirectURL or https://my.realdevsquad.com/new-signup if user details are incomplete.
72+
73+
```
74+
Location: {redirectURL}
75+
```
76+
- **Cookie**: A secure JWT authentication token (rds-session) is set as a cookie to maintain the user's session.
77+
```
78+
Set-Cookie: rds-session=<jwt_token>; Domain={realdevsqual.com}; Expires={expirationTime}; HttpOnly; Secure; SameSite=Lax
79+
```
80+
81+
- **Error Response:**
82+
- **Code:** 401
83+
- **Content:**
84+
85+
```json
86+
{
87+
"statusCode": 401,
88+
"error": "Unauthorized",
89+
"message": "User cannot be authenticated"
90+
}
91+
```
92+
- **Code:** 500
93+
94+
- **Content:**
95+
96+
```json
97+
{
98+
"statusCode": 500,
99+
"error": "Internal Server Error",
100+
"message": "An internal server error occurred"
101+
}
102+
```
103+
## GET /auth/github/login
104+
105+
Initiates the GitHub OAuth authentication process by redirecting the user to GitHub's consent screen.
106+
107+
- **Params**
108+
None
109+
110+
- **Query**
111+
- Optional: `redirectURL=[string]` (The URL to redirect the user to after authentication is successful. It should be a valid URL.)
112+
113+
### Response
114+
115+
- **Success Response**:
116+
- **Code:** 302
117+
118+
- **Content:** Redirects to GitHub's OAuth 2.0 consent screen for user authentication.
119+
120+
```text
121+
Location: Location: https://github.com/login/oauth/authorize?client_id={CLIENT_ID}&redirect_uri={REDIRECT_URI}&response_type=code&scope=user:email&state={state}
122+
```
123+
124+
- **Error Response:**
125+
- **Code:** 401
126+
- **Content:**
127+
128+
```json
129+
{
130+
"statusCode": 401,
131+
"error": "Unauthorized",
132+
"message": "User cannot be authenticated"
133+
}
134+
```
135+
- **Code:** 500
136+
137+
- **Content:**
138+
139+
```json
140+
{
141+
"statusCode": 500,
142+
"error": "Internal Server Error",
143+
"message": "An internal server error occurred"
144+
}
145+
```
146+
147+
## GET /auth/github/callback
148+
149+
Handles the callback from GitHub after the user authenticates, exchanges the authorization code for an access token, and completes the user login process.
150+
151+
- **Params**
152+
None
153+
154+
- **Query**
155+
- Required: `code=[string]` (The authorization code returned by GitHub after the user grants consent.)
156+
- Required: `state=[string]` (The state parameter returned by GitHub, used to verify the request’s legitimacy and ensure security.)
157+
158+
### Response
159+
67160
- **Success Response**:
68161
- **Code**: 302
69162
- **Content**: Redirects to the specified redirectURL or https://my.realdevsquad.com/new-signup if user details are incomplete.

0 commit comments

Comments
 (0)