From be822692064767ee77e459c84929b1baafe26b6f Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Sun, 15 Dec 2024 13:21:16 +0200 Subject: [PATCH] Update OAuth2.md --- OAuth2.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/OAuth2.md b/OAuth2.md index 660faf0..1c7fcb8 100644 --- a/OAuth2.md +++ b/OAuth2.md @@ -189,7 +189,7 @@ export default Callback; 4. The backend will exchange the `code` for an `access_token` and `refresh_token`, which are sent back to the frontend or stored securely for subsequent API calls.
-

HTTP Request

+

Backend HTTP Request to Google

- `HTTP` Method: POST - `URL`: https://oauth2.googleapis.com/token @@ -216,7 +216,7 @@ client_secret=YOUR_GOOGLE_CLIENT_SECRET
-

HTTP Response

+

HTTP Response from Google

```json { @@ -231,7 +231,7 @@ client_secret=YOUR_GOOGLE_CLIENT_SECRET
-

Example Backend Code:

+

Backend Code:

```js const express = require('express'); @@ -291,7 +291,7 @@ 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
-

HTTP Request

+

Frontend HTTP Request to Backend

```bash GET https://xorismesiti.gr/api/user-profile @@ -301,7 +301,7 @@ Authorization: Bearer access-token-from-backend
-

HTTP Response

+

Frontend HTTP Response from Backend

```json { @@ -320,7 +320,7 @@ Authorization: Bearer access-token-from-backend
-

Example Frontend Code:

+

Frontend Code:

```js // After receiving the token, store it in the frontend (e.g., localStorage or context) @@ -398,7 +398,7 @@ Authorization: Bearer ya29.a0AfH6SMC8Op6zXZkHi2XITkDoOVzYXt3hTY6sny54UlWlxrnKlX5
-

Example Backend Code:

+

Backend Code:

```js app.get('/api/user-profile', async (req, res) => {