Update OAuth2.md
This commit is contained in:
parent
584d5b1958
commit
a0614514e8
34
OAuth2.md
34
OAuth2.md
@ -263,8 +263,6 @@ 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
|
the frontend can use it to make authenticated requests to the backend or Google APIs
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><h3>HTTP Request</h3></summary>
|
<summary><h3>HTTP Request</h3></summary>
|
||||||
|
|
||||||
@ -318,12 +316,44 @@ fetch('/api/user-profile', {
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
<br><br><br>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 5. [Backend] Fetch User Data
|
# 5. [Backend] Fetch User Data
|
||||||
|
|
||||||
If you want to fetch the user profile data (e.g., from Google), your backend can use the `access_token` to request it from Google’s user info endpoint.
|
If you want to fetch the user profile data (e.g., from Google), your backend can use the `access_token` to request it from Google’s user info endpoint.
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><h3>HTTP Request</h3></summary>
|
||||||
|
|
||||||
|
```bash
|
||||||
|
GET https://www.googleapis.com/oauth2/v3/userinfo
|
||||||
|
Authorization: Bearer access-token-from-backend
|
||||||
|
```
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary><h3>HTTP Request</h3></summary>
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"sub": "1234567890",
|
||||||
|
"name": "John Doe",
|
||||||
|
"given_name": "John",
|
||||||
|
"family_name": "Doe",
|
||||||
|
"profile": "https://plus.google.com/1234567890",
|
||||||
|
"picture": "https://lh3.googleusercontent.com/a-/AOh14GgIXXl5JXzW0c1Szbl-e1Jch1vhl5rHhH65vlK6J5g5PqkGjj1O0p3t8bgVEOykQ6ykFSQ=s96",
|
||||||
|
"email": "john.doe@example.com",
|
||||||
|
"email_verified": true,
|
||||||
|
"locale": "en"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><h3>Example Backend Code:</h3></summary>
|
<summary><h3>Example Backend Code:</h3></summary>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user