From b88ebbe13d79b66626cde8d118948bb233abb3c6 Mon Sep 17 00:00:00 2001 From: Ste Vaidis Date: Sun, 15 Dec 2024 13:25:55 +0200 Subject: [PATCH] Update OAuth2.md --- OAuth2.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OAuth2.md b/OAuth2.md index 7c6b12c..b2517c7 100644 --- a/OAuth2.md +++ b/OAuth2.md @@ -42,7 +42,7 @@ A way for the `user` to tell `google` to give an access token to `xorismesiti.gr 3. Google will redirect the user back to your specified redirect_uri with an authorization code.
-

Frontend HTTP Request to Google

+

Frontend HTTP GET Request to Google

```sh GET https://accounts.google.com/o/oauth2/v2/auth? @@ -106,7 +106,7 @@ const loginWithGoogle = () => {
-

Frontend HTTP Request to Backend

+

Frontend HTTP POST Request to Backend

```bash POST https://xorismesiti.gr/api/auth/exchange-token @@ -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.
-

Backend HTTP Request to Google

+

Backend HTTP POST Request to Google

- `HTTP` Method: POST - `URL`: https://oauth2.googleapis.com/token @@ -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
-

Frontend HTTP Request to Backend

+

Frontend HTTP GET Request to Backend

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

Frontend Code:

+

Frontend Code

```js // After receiving the token, store it in the frontend (e.g., localStorage or context) @@ -362,7 +362,7 @@ your platform can now use it to fetch the user's Google profile and email inform The token is included in the Authorization header of the request.
-

HTTP Request

+

HTTP GET Request

```sh GET https://www.googleapis.com/oauth2/v3/userinfo @@ -398,7 +398,7 @@ Authorization: Bearer ya29.a0AfH6SMC8Op6zXZkHi2XITkDoOVzYXt3hTY6sny54UlWlxrnKlX5
-

Backend Code:

+

Backend GET Code

```js app.get('/api/user-profile', async (req, res) => { @@ -438,7 +438,7 @@ your platform can use the refresh token (if provided) to obtain a new access tok
-

HTTP Request

+

HTTP POST Request

```bash POST https://oauth2.googleapis.com/token