Skip to content

Social SDK: Add example for client-RefreshToken(...) #7561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down