Skip to content

Commit f1c0962

Browse files
spenhandmarkmandel
andauthored
[docs] Add bot token unmerge endpoint documentation (#7886)
* Add bot token unmerge endpoint documentation Document the new /provisional-accounts/unmerge/bot endpoint that allows unmerging provisional accounts using just the bot token and external_user_id, without requiring an external auth token. This ensures identities can always be removed even if the external auth token is no longer accessible. * Review edit Add "Tip" for being able to recover an account that's lost its auth token due to data loss or error. --------- Co-authored-by: Mark Mandel <[email protected]>
1 parent 389a912 commit f1c0962

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

discord/developers/docs/discord-social-sdk/development-guides/using-provisional-accounts.mdx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,32 @@ def unmerge_provisional_account(external_auth_token):
496496
If you have a server backend, you'll want to use the server-to-server unmerge endpoint rather than the SDK helper method to maintain better security and control over the unmerge process.
497497
</Info>
498498

499+
#### Unmerging with Bot Token Endpoint
500+
501+
If you're using the [Bot Token Endpoint](/docs/discord-social-sdk/development-guides/using-provisional-accounts#server-authentication-with-bot-token-endpoint) for authentication, you can unmerge accounts without an external auth token.
502+
503+
```python
504+
import requests
505+
506+
API_ENDPOINT = 'https://discord.com/api/v10'
507+
BOT_TOKEN = 'YOUR_BOT_TOKEN'
508+
509+
def unmerge_provisional_account(external_user_id):
510+
data = {
511+
'external_user_id': external_user_id # identifier used in the /token/bot endpoint
512+
}
513+
headers = {
514+
'Content-Type': 'application/json',
515+
'Authorization': f'Bot {BOT_TOKEN}'
516+
}
517+
r = requests.post('%s/provisional-accounts/unmerge/bot' % API_ENDPOINT, json=data, headers=headers)
518+
r.raise_for_status()
519+
```
520+
521+
<Tip>
522+
This endpoint can also be useful in cases where the Discord Auth token has been lost to to error or data loss, and an unmerge operation is required to migrate to a provisional account before re-linking a Discord account.
523+
</Tip>
524+
499525
### Unmerging Provisional Accounts for Public Clients
500526

501527
<PublicClient />
@@ -621,4 +647,4 @@ import {UserStatusIcon} from '/snippets/icons/UserStatusIcon.jsx'
621647
[`Client::GetTokenFromProvisionalMerge`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a41062b7dafa331ddd2320daf1b4b273b
622648
[`Client::SetTokenExpirationCallback`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#aab5bfc76809ea22e79f2f7a067ac4519
623649
[`Client::UnmergeIntoProvisionalAccount`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a2da21ae8a3015e0e5e42c1a7226b256f
624-
[`Client::UpdateProvisionalAccountDisplayName`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7485979ab2d4c533b75f8efd5e50bc60
650+
[`Client::UpdateProvisionalAccountDisplayName`]: https://discord.com/developers/docs/social-sdk/classdiscordpp_1_1Client.html#a7485979ab2d4c533b75f8efd5e50bc60

0 commit comments

Comments
 (0)