Unbind Third-Party Account
DELETE/auth/v1/user/provider/:provider_id
API Description
Unbind third-party account API, used to remove the binding relationship between the current logged-in user and specified third-party identity source (such as GitHub, WeChat, QQ, etc.).
Input Requirements
Required Parameters
provider_id: Identity source ID (required, path parameter, such as wx_open, github, wechat, etc.)Authorization: Current logged-in user's access_token (required, passed in request header, format Bearer xxx)
Optional Parameters
with_user_center: Whether to record in user centralized security log (optional, boolean, default false)client_id: Client ID (optional, defaults to environment ID)x-device-id: Device ID (optional, passed in request header)
Prerequisites
- User must be logged in (need valid access_token)
- The identity source must already be bound to current user
- Can first call Get List of Third-Party Identity Sources Bound to Account API to view bound identity sources
Output Description
Successful Response
- Returns empty object
{}, indicating successful unbinding
Request Example
Unbind GitHub Account Request Example
DELETE /auth/v1/user/provider/github?with_user_center=true
Headers:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2FwaS5leGFtcGxlLmNvbSIsInN1YiI6Ijk4NzY1NDMyMTAxMjM0NTY3ODkiLCJhdWQiOiJkZW1vLWFwcC0yZjhhOWMzZTFiNGQiLCJleHAiOjE3MzQ2NzU4ODksImlhdCI6MTczNDY2ODY4OSwic2NvcGUiOiJ1c2VyIn0.dGhpc19pc19hX2Zha2Vfc2lnbmF0dXJlX2Zvcl9leGFtcGxlX3B1cnBvc2VzX29ubHlfZG9fbm90X3VzZV9pbl9wcm9kdWN0aW9uX2Vudmlyb25tZW50X3RoaXNfaXNfbm90X3JlYWxfdG9rZW5fZGF0YQ
x-device-id: device_abc123
Unbinding Success Response Example
{}
Not Logged In Response Example
{
"error": "unauthorized",
"error_code": 4003,
"error_description": "User not logged in or access_token invalid"
}
Identity Source Not Found Response Example
{
"error": "provider_not_found",
"error_code": 4004,
"error_description": "Specified identity source does not exist"
}
Field Description
Request Parameters
| Field Name | Type | Required | Location | Description |
|---|---|---|---|---|
| provider_id | string | Yes | path | Identity source ID, such as wx_open, github, wechat, qq, etc. |
| Authorization | string | Yes | header | Current logged-in user's access_token, format Bearer xxx |
| with_user_center | boolean | No | query | Whether to record in user centralized security log, default false |
| client_id | string | No | query | Client ID, defaults to environment ID |
| x-device-id | string | No | header | Device ID |
Response Parameters
| Field Name | Type | Required | Description |
|---|---|---|---|
| - | object | Yes | Returns empty object {} on success |
Usage Flow
Complete Unbinding Flow
1. View Bound Identity Sources
- Call Get List of Third-Party Identity Sources Bound to Account API
- Get list of identity sources currently bound to user
- Confirm identity source ID to unbind
2. Confirm Unbinding Operation
- Prompt user to confirm unbinding operation
- Explain impact after unbinding
- Ensure at least one login method is retained
3. Execute Unbinding
- Call this API
- Pass provider_id to unbind
- Pass valid access_token
4. Handle Result
- Unbinding success: Update UI, remove the identity source
- Unbinding failure: Display error message, prompt user
Notes
AccessToken
- Must be valid access_token
- Must be passed in request header
- Format must be Bearer xxx
- Need to re-login when token expires
Provider ID
- Must be already bound identity source ID
- Must be valid identity source
- Can query through list API
Impact After Unbinding
- Cannot login using this identity source anymore
- Need to use other bound methods to login
- Can re-bind anytime
- Does not affect user's other data
Error Handling
Common Errors
unauthorized: User not logged in or access_token invalidprovider_not_found: Specified identity source does not existinternal_error: Server internal error
Error Handling Strategy
- Identity source not bound: Prompt user that identity source is not bound
- Cannot unbind last one: Prompt user to keep at least one login method
- Not logged in: Redirect to login page
- Identity source does not exist: Prompt user to select valid identity source
- Server error: Retry later or contact customer service
Related APIs
- Get List of Third-Party Identity Sources Bound to Account - View bound identity sources
- Bind Third-Party Account - Bind new third-party account
- Get Third-Party Login Callback URL - Get authorization URL
- Get Third-Party Authorization Info - Get provider_token
Request
Path Parameters
Identity source ID, such as wx_open, or WeChat Mini Program appid
Query Parameters
Client ID corresponding to the application, can be obtained from Cloud Development Platform -> Identity Authentication -> Development Settings. Defaults to environment ID, can be omitted
Whether to record in the user centralized security log
Header Parameters
Device ID, the ID of the current logged-in device. The client should generate it randomly and cache it on the client. This parameter is related to the number of logged-in accounts.
The access_token of the current logged-in user, format is Bearer xxx
- application/json
Body
- any
Responses
- 200
- 500
A successful response.
Response Headers
- application/json
- Schema
Schema
- any
An unexpected error response.
Response Headers
- application/json
- Schema
- Example (from schema)
Schema
{
"error": "string",
"error_code": 0,
"error_description": "string"
}