Update OAuth2.md

This commit is contained in:
Ste Vaidis 2024-12-15 14:58:57 +02:00
parent 92e11e2c45
commit c7200fabb5

View File

@ -190,17 +190,6 @@ export default Callback;
<details> <details>
<summary><h3>Backend HTTP POST Request to Google</h3></summary> <summary><h3>Backend HTTP POST Request to Google</h3></summary>
- `HTTP` Method: POST
- `URL`: https://oauth2.googleapis.com/token
- `Headers`:
- `Content`-Type: application/x-www-form-urlencoded
- `Body` Parameters:
- `grant_type`=authorization_code: This specifies the grant type.
- `code`: The authorization code you received in the previous step.
- `redirect_uri`: The same redirect URI used in the authorization request.
- `client_id`: Your Google API client ID.
- `client_secret`: Your Google API client secret (which should be kept secure).
```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
@ -212,6 +201,17 @@ client_id=ABC34JHS9D&
client_secret=PASS1234 client_secret=PASS1234
``` ```
- `HTTP Method`: POST
- `URL`: https://oauth2.googleapis.com/token
- Headers
- `Content-Type`: application/x-www-form-urlencoded
- Body
- `grant_type`=authorization_code: This specifies the grant type.
- `code`: The authorization code you received in the previous step.
- `redirect_uri`: The same redirect URI used in the authorization request.
- `client_id`: Your Google API client ID.
- `client_secret`: Your Google API client secret (which should be kept secure).
</details> </details>
<details> <details>
@ -285,9 +285,11 @@ app.listen(3000, () => {
# 4. [Frontend] Use the Token # 4. [Frontend] Use the Token
Once the backend exchanges the `code` for the `access_token`, Once the backend exchanges the `code` for the `access_token`,
the frontend can use it to make authenticated requests to the backend or Google APIs incude these tokens to POST reponse recieved from frontend,
so that the frontend can use it to make authenticated requests to the backend or Google APIs
<details> <details>
<summary><h3>Frontend HTTP GET Request to Backend</h3></summary> <summary><h3>Frontend HTTP GET Request to Backend</h3></summary>