Skip to content

Commit d77c8ba

Browse files
Merge pull request #210 from listiclehub1/api-contract-github-auth
Added api contract for github auth
2 parents 490ad71 + dab263f commit d77c8ba

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed

auth/README.md

Lines changed: 94 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

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

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

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

0 commit comments

Comments
 (0)