You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a user wants to disconnect their Discord account or if a token is compromised, you can revoke access and refresh tokens.
232
232
233
+
:::warn
234
+
When any valid access or refresh token is revoked, all of your application's access and refresh tokens for that user are immediately invalidated.
235
+
:::
236
+
237
+
### Revoking Access Tokens for Public Clients
238
+
239
+
<PublicClient />
240
+
241
+
The easiest way to revoke tokens is using the SDK's `Client::RevokeToken` method. This will invalidate all access and refresh tokens for the user and they cannot be used again.
242
+
243
+
```cpp
244
+
client->RevokeToken(YOUR_DISCORD_APPLICATION_ID,
245
+
accessToken, // Can also use refresh token
246
+
[](constdiscordpp::ClientResult&result) {
247
+
if (!result.Successful()) {
248
+
std::cout
249
+
<<"? Error revoking token: "<<result.Error()
250
+
<<std::endl;
251
+
return;
252
+
}
253
+
254
+
std::cout
255
+
<<"? Token successfully revoked! User logged out."
256
+
<<std::endl;
257
+
// Handle successful logout (clear stored tokens,
258
+
// redirect to login, etc.)
259
+
});
260
+
```
261
+
233
262
### Server-to-Server Token Revocation
234
263
264
+
If your application uses a backend server, you can revoke tokens by making an API request to Discord's token revocation endpoint.
0 commit comments