From 5556360d0b3da40efab7e31e54d8f13304bafd6e Mon Sep 17 00:00:00 2001 From: Dennis Cheng Date: Thu, 2 Oct 2025 17:18:43 +0000 Subject: [PATCH 1/3] boop --- .../core-concepts/oauth2-scopes.mdx | 6 +-- .../account-linking-with-discord.mdx | 40 +++++++++---------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx b/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx index 32a45f30c1..afeab00637 100644 --- a/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx +++ b/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx @@ -62,12 +62,12 @@ See [available OAuth2 scopes](/docs/topics/oauth2#shared-resources-oauth2-scopes ## OAuth2 Client Types -OAuth2 has two client types: **Public** and **Confidential**. Most games will not want to ship with **Public Client** enabled. +OAuth2 has two client types: **Confidential** and **Public**. Most games will not want to ship with **Public Client** enabled. 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**. -- Public clients cannot securely store client secrets. - Using confidential clients with proper secret management for production applications is generally recommended. +- Public clients cannot securely store client secrets. - Your security team should review this setting and authentication flows before releasing your game. [Learn more about OAuth2 client types](https://oauth.net/2/client-types) @@ -104,4 +104,4 @@ Start your integration, implement user authentication, and learn about UI design [`AuthorizationArgs::SetScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1AuthorizationArgs.html#aa3714d11a196e0d71c8c1cf38c506d92 [`Client::Authorize`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#ace94a58e27545a933d79db32b387a468 [`Client::GetDefaultCommunicationScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a71499da752fbdc2d4326ae0fd36c0dd1 -[`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c \ No newline at end of file +[`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c diff --git a/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx b/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx index 99b71aeb5b..6a95e41791 100644 --- a/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx +++ b/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx @@ -108,25 +108,6 @@ Once the user approves the request from Step 2, Discord will redirect the user b #### Token Exchange for Public Clients - - -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. - -We will also need the code verifier used to generate the code challenge in Step 1. - -```cpp -client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri, - [client](discordpp::ClientResult result, - std::string accessToken, - std::string refreshToken, - discordpp::AuthorizationTokenType tokenType, - int32_t expiresIn, - std::string scope) { - std::cout << "🔓 Access token received! Establishing connection...\n"; - // Next step: Update the token in the client and connect to Discord - }); -``` - #### Server-to-Server Get Token Exchange 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): } ``` + + +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. + +We will also need the code verifier used to generate the code challenge in Step 1. + +```cpp +client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri, + [client](discordpp::ClientResult result, + std::string accessToken, + std::string refreshToken, + discordpp::AuthorizationTokenType tokenType, + int32_t expiresIn, + std::string scope) { + std::cout << "🔓 Access token received! Establishing connection...\n"; + // Next step: Update the token in the client and connect to Discord + }); +``` + --- ## Working with Tokens @@ -322,4 +322,4 @@ Now that you've successfully implemented account linking with Discord, you can i [`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c [`Client::GetToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#aaee636f91fb1ea3465157c20313b702c [`Client::RefreshToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a187af0f99f94b3b9a4ad4302f6a443e7 -[`Client::UpdateToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a606b32cef7796f7fb91c2497bc31afc4 \ No newline at end of file +[`Client::UpdateToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a606b32cef7796f7fb91c2497bc31afc4 From 228ab6c8eec207473087c22bd145f03adf86980d Mon Sep 17 00:00:00 2001 From: Dennis Cheng Date: Thu, 2 Oct 2025 17:21:45 +0000 Subject: [PATCH 2/3] oops --- .../development-guides/account-linking-with-discord.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx b/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx index 6a95e41791..ae5b12799c 100644 --- a/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx +++ b/docs/discord-social-sdk/development-guides/account-linking-with-discord.mdx @@ -322,4 +322,4 @@ Now that you've successfully implemented account linking with Discord, you can i [`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c [`Client::GetToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#aaee636f91fb1ea3465157c20313b702c [`Client::RefreshToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a187af0f99f94b3b9a4ad4302f6a443e7 -[`Client::UpdateToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a606b32cef7796f7fb91c2497bc31afc4 +[`Client::UpdateToken`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a606b32cef7796f7fb91c2497bc31afc4 \ No newline at end of file From f09de065a4961e52b74e0367c54c6dfac2ed529e Mon Sep 17 00:00:00 2001 From: Dennis Cheng Date: Thu, 2 Oct 2025 17:24:12 +0000 Subject: [PATCH 3/3] one more --- docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx b/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx index afeab00637..4c9ef8ebc8 100644 --- a/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx +++ b/docs/discord-social-sdk/core-concepts/oauth2-scopes.mdx @@ -104,4 +104,4 @@ Start your integration, implement user authentication, and learn about UI design [`AuthorizationArgs::SetScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1AuthorizationArgs.html#aa3714d11a196e0d71c8c1cf38c506d92 [`Client::Authorize`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#ace94a58e27545a933d79db32b387a468 [`Client::GetDefaultCommunicationScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a71499da752fbdc2d4326ae0fd36c0dd1 -[`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c +[`Client::GetDefaultPresenceScopes`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7648bd1d2f7d9a86ebd0edb8bef12b5c \ No newline at end of file