Access Tokens
Each authentication method returns a Discord access token that expires after 7 days. You use it with the SDK just like a full Discord user’s access token.Refreshing Access Tokens
While we’d recommend generating a new access token whenever a user starts a session, you can also be notified when the access token is about to expire. UseClient::SetTokenExpirationCallback to receive a callback when the current token is about to expire or has expired, so you can refresh it without interrupting the user’s experience.
When the token expires, re-call the same method you used originally to obtain a new access token, then pass it to Client::UpdateToken.
When the token expires, the SDK will still receive updates, such as new messages sent in a lobby, and any voice calls will continue to be active. However, any new actions, such as sending a message or adding a friend, will fail. You can get a new token and pass it to
Client::UpdateToken without interrupting the user’s experience.If you are using Server Authentication with OIDC, a
refresh_token is returned but using it via the OAuth2 refresh_token grant is deprecated. Re-authenticate using a fresh provider token instead.Storing Access Tokens
It is suggested that these provisional tokens are not stored and instead invoke this function each time the game is launched and when these tokens are about to expire. However, should you choose to store it, it is recommended that these provisional account tokens be differentiated from “full” Discord account tokens.Setting Display Names
Using these credentials, we’ll create a limited Discord account just for your game and try to set the username for you according to the following:- For Bot issued tokens, the
preferred_global_nameyou specified will be used. - For OIDC, a provisional account’s display name will be the value of the
preferred_usernameclaim, if specified in the ID token. This field is optional and should be between 1 and 32 characters. If not specified, the user’s display name will default to the user’s unique username, which Discord generates on creation. - For Steam session tickets, the display name of the user’s Steam account is used as the provisional account’s display name.
- For EOS Auth Access Tokens or ID Tokens,
the name of the user’s Epic account is used as the provisional account’s display name. EOS Connect ID Tokens do
not expose any username, and thus the game will need to configure the display name with
Client::UpdateProvisionalAccountDisplayName. - For Unity Services ID Tokens, the display name of the user’s Unity Player Account is used as the provisional account’s display name.
Client::UpdateProvisionalAccountDisplayName method.
Next Steps
Merging Accounts
Merge a provisional account into a full Discord account.
Unmerging Accounts
Sever the link between a Discord account and a provisional account.
Designing for Provisional Accounts
Design guidelines for implementing provisional accounts in your game.
#social-sdk-dev-help channel for support from the community.
If you encounter a bug while working with the Social SDK, please report it here: https://dis.gd/social-sdk-bug-report