Skip to content

Commit 03bb960

Browse files
authored
Social SDK: Add example for client-RefreshToken(...) (#7561)
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).
1 parent 30cb533 commit 03bb960

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ If your app does not have a backend server, enable `Public Client` in the Discor
111111
We will also need the code verifier used to generate the code challenge in Step 1.
112112
113113
```cpp
114-
client->GetToken(APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri,
114+
client->GetToken(YOUR_DISCORD_APPLICATION_ID, code, codeVerifier.Verifier(), redirectUri,
115115
[client](discordpp::ClientResult result,
116116
std::string accessToken,
117117
std::string refreshToken,
@@ -185,7 +185,21 @@ Access tokens expire after 7 days, requiring refresh tokens to get a new one.
185185
The easiest way to refresh tokens is using the SDK's [`Client::RefreshToken`] method.
186186
187187
``` cpp
188-
client->RefreshToken();
188+
client->RefreshToken(
189+
YOUR_DISCORD_APPLICATION_ID, GetRefreshToken(),
190+
[client](discordpp::ClientResult result, std::string accessToken,
191+
std::string refreshToken,
192+
discordpp::AuthorizationTokenType tokenType, int32_t expiresIn,
193+
std::string scope) {
194+
if (!result.Successful()) {
195+
std::cout << "❌ Error refreshing token: " << result.Error()
196+
<< std::endl;
197+
return;
198+
}
199+
200+
// Update token and connect
201+
UpdateToken(client, refreshToken, accessToken);
202+
});
189203
```
190204
191205
### Server-to-Server Token Refresh

0 commit comments

Comments
 (0)