You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/guide/content/docs/legacy/oauth2/oauth2.mdx
+4-50Lines changed: 4 additions & 50 deletions
Original file line number
Diff line number
Diff line change
@@ -75,56 +75,10 @@ The `identify` scope will allow your application to get basic user information f
75
75
76
76
### Implicit grant flow
77
77
78
-
You have your website, and you have a URL. Now you need to use those two things to get an access token. For basic applications like [SPAs](https://en.wikipedia.org/wiki/Single-page_application), getting an access token directly is enough. You can do so by changing the `response_type` in the URL to `token`. However, this means you will not get a refresh token, which means the user will have to explicitly re-authorize when this access token has expired.
79
-
80
-
After you change the `response_type`, you can test the URL right away. Visiting it in your browser, you will be directed to a page that looks like this:
You can see that by clicking `Authorize`, you allow the application to access your username and avatar. Once you click through, it will redirect you to your redirect URL with a [fragment identifier](https://en.wikipedia.org/wiki/Fragment_identifier) appended to it. You now have an access token and can make requests to Discord's API to get information on the user.
85
-
86
-
Modify `index.html` to add your OAuth2 URL and to take advantage of the access token if it exists. Even though [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) is for working with query strings, it can work here because the structure of the fragment follows that of a query string after removing the leading "#".
Here you grab the access token and type from the URL if it's there and use it to get info on the user, which is then used to greet them. The response you get from the [`/api/users/@me` endpoint](https://discord.com/developers/docs/resources/user#get-current-user) is a [user object](https://discord.com/developers/docs/resources/user#user-object) and should look something like this:
116
-
117
-
```json
118
-
{
119
-
"id": "123456789012345678",
120
-
"username": "User",
121
-
"discriminator": "0001",
122
-
"avatar": "1cc0a3b14aec3499632225c708451d67",
123
-
...
124
-
}
125
-
```
126
-
127
-
In the following sections, we'll go over various details of Discord and OAuth2.
78
+
<Callouttype="error">
79
+
Implicit grant flow, as previously covered in this section, is vulnerable to token leakage and replay attacks. Please
80
+
use the **authorization grant** flow instead. The [Oauth2 RFC](https://datatracker.ietf.org/doc/html/rfc9700).
0 commit comments