From 411583c60ea3c30637231b85fd839f05c0257d3d Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Fri, 16 May 2025 22:51:33 +0000 Subject: [PATCH] Social SDK: Add example for `client-RefreshToken(...)` There wasn't a valid example for `client->RefreshToken(...)`, and now there is! Also made `YOUR_DISCORD_APPLICATION_ID` consistent across the page (one change). --- .../account-linking-with-discord.mdx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) 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 d1c2307c18..9ad092293d 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 @@ -111,7 +111,7 @@ If your app does not have a backend server, enable `Public Client` in the Discor We will also need the code verifier used to generate the code challenge in Step 1. ```cpp -client->GetToken(APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri, +client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri, [client](discordpp::ClientResult result, std::string accessToken, std::string refreshToken, @@ -185,7 +185,21 @@ Access tokens expire after 7 days, requiring refresh tokens to get a new one. The easiest way to refresh tokens is using the SDK's [`Client::RefreshToken`] method. ``` cpp -client->RefreshToken(); +client->RefreshToken( + YOUR_DISCORD_APPLICATION_ID, GetRefreshToken(), + [client](discordpp::ClientResult result, std::string accessToken, + std::string refreshToken, + discordpp::AuthorizationTokenType tokenType, int32_t expiresIn, + std::string scope) { + if (!result.Successful()) { + std::cout << "❌ Error refreshing token: " << result.Error() + << std::endl; + return; + } + + // Update token and connect + UpdateToken(client, refreshToken, accessToken); + }); ``` ### Server-to-Server Token Refresh