Update OAuth2-Backend-Approach.md
This commit is contained in:
parent
5747b4078a
commit
e6e6d60ff0
@ -44,7 +44,7 @@ A way for the `user` to tell `google` to give an access to `xorismesiti.gr` app
|
|||||||
1. Front **GET** to Google `https://accounts.google.com/o/oauth2` with callback url
|
1. Front **GET** to Google `https://accounts.google.com/o/oauth2` with callback url
|
||||||
2. Google **302** to Back `https://xorismesiti.gr/api/auth/callback` with authorization code
|
2. Google **302** to Back `https://xorismesiti.gr/api/auth/callback` with authorization code
|
||||||
|
|
||||||
### Front **GET** to Google
|
### 1. Front **GET** to Google
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
GET https://accounts.google.com/o/oauth2/v2/auth?
|
GET https://accounts.google.com/o/oauth2/v2/auth?
|
||||||
@ -55,7 +55,7 @@ GET https://accounts.google.com/o/oauth2/v2/auth?
|
|||||||
state=xyz123 # A random string to protect against CSRF attacks.
|
state=xyz123 # A random string to protect against CSRF attacks.
|
||||||
```
|
```
|
||||||
|
|
||||||
### Google **302** to Back
|
### 2. Google **302** to Back
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
HTTP/1.1 302 Found
|
HTTP/1.1 302 Found
|
||||||
@ -77,8 +77,6 @@ Content-Length: 0
|
|||||||
|
|
||||||
### 1. Back **POST** the `code` to Google
|
### 1. Back **POST** the `code` to Google
|
||||||
|
|
||||||
The Backend **POST** to Google
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
POST https://oauth2.googleapis.com/token
|
POST https://oauth2.googleapis.com/token
|
||||||
Content-Type: application/x-www-form-urlencoded
|
Content-Type: application/x-www-form-urlencoded
|
||||||
@ -90,7 +88,8 @@ client_id=ABC34JHS9D&
|
|||||||
client_secret=PASS1234
|
client_secret=PASS1234
|
||||||
```
|
```
|
||||||
|
|
||||||
The Google **response**
|
### 2. Google **response** to Back
|
||||||
|
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
@ -101,8 +100,7 @@ The Google **response**
|
|||||||
"scope": "email profile"
|
"scope": "email profile"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
### 3. Back **response** to Front
|
||||||
The Backend Code
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// Backend callback URL: http://localhost:3000/auth/google/callback
|
// Backend callback URL: http://localhost:3000/auth/google/callback
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user