Skip to content

Commit 76ca34c

Browse files
authored
[sdk] reorder public and confidential clients (discord#7877)
list confidential clients before public, since we recommend the former
1 parent 0193334 commit 76ca34c

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ See [available OAuth2 scopes](/docs/topics/oauth2#shared-resources-oauth2-scopes
6262

6363
## OAuth2 Client Types
6464

65-
OAuth2 has two client types: **Public** and **Confidential**. Most games will not want to ship with **Public Client** enabled.
65+
OAuth2 has two client types: **Confidential** and **Public**. Most games will not want to ship with **Public Client** enabled.
6666

6767
Some Social SDK methods require your Discord application to be a **Public Client**. These methods also have server-side alternatives that you can use with a **Confidential Client**.
6868

69-
- Public clients cannot securely store client secrets.
7069
- Using confidential clients with proper secret management for production applications is generally recommended.
70+
- Public clients cannot securely store client secrets.
7171
- Your security team should review this setting and authentication flows before releasing your game.
7272

7373
[Learn more about OAuth2 client types](https://oauth.net/2/client-types)

docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,6 @@ Once the user approves the request from Step 2, Discord will redirect the user b
108108
109109
#### Token Exchange for Public Clients
110110
111-
<PublicClient />
112-
113-
If your app does not have a backend server, enable `Public Client` in the Discord Developer Portal and use [`Client::GetToken`] to automatically exchange the authorization code for a token.
114-
115-
We will also need the code verifier used to generate the code challenge in Step 1.
116-
117-
```cpp
118-
client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri,
119-
[client](discordpp::ClientResult result,
120-
std::string accessToken,
121-
std::string refreshToken,
122-
discordpp::AuthorizationTokenType tokenType,
123-
int32_t expiresIn,
124-
std::string scope) {
125-
std::cout << "🔓 Access token received! Establishing connection...\n";
126-
// Next step: Update the token in the client and connect to Discord
127-
});
128-
```
129-
130111
#### Server-to-Server Get Token Exchange
131112
132113
If your application uses a backend server and does **not** have `Public Client` enabled, you can manually exchange the authorization code for an access token using the Discord API.
@@ -162,6 +143,25 @@ def exchange_code(code, redirect_uri):
162143
}
163144
```
164145

146+
<PublicClient />
147+
148+
If your app does not have a backend server, enable `Public Client` in the Discord Developer Portal and use [`Client::GetToken`] to automatically exchange the authorization code for a token.
149+
150+
We will also need the code verifier used to generate the code challenge in Step 1.
151+
152+
```cpp
153+
client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri,
154+
[client](discordpp::ClientResult result,
155+
std::string accessToken,
156+
std::string refreshToken,
157+
discordpp::AuthorizationTokenType tokenType,
158+
int32_t expiresIn,
159+
std::string scope) {
160+
std::cout << "🔓 Access token received! Establishing connection...\n";
161+
// Next step: Update the token in the client and connect to Discord
162+
});
163+
```
164+
165165
---
166166
167167
## Working with Tokens

0 commit comments

Comments
 (0)