Force logout
Use Force logout to sign a user out from a specific platform. OpenIM marks the corresponding token as kicked, asks the gateway to close that connection, and the client SDK receives the kicked-offline callback. Configure the API address as described in Prepare to use the API, and keep the administrator token on the backend only.
HTTP request
POST {API_ADDRESS}/auth/force_logoutRequest example
curl --request POST "${API_ADDRESS}/auth/force_logout" \
--header "Content-Type: application/json; charset=utf-8" \
--header "operationID: ${OPERATION_ID}" \
--header "token: ${ADMIN_TOKEN}" \
--data-raw '{
"platformID": 2,
"userID": "user_001"
}'Parameters
This endpoint accepts tracing and authentication information in request headers and business parameters in a JSON request body.
Request headers
| Header | Required | Type | Description |
|---|---|---|---|
| operationID | Yes | string | A unique tracing ID for this request. Generate it on the backend and include it in application logs. |
| token | Yes | string | An application administrator token. Keep it on the backend only. |
| Content-Type: application/json | Yes | string | Required when the request body is JSON. |
Request body
{
"platformID": 2,
"userID": "user_001"
}| Parameter | Required | Type | Description |
|---|---|---|---|
| platformID | Yes | int | The platform from which the user must be signed out. See PlatformID. |
| userID | Yes | string | The user to sign out. |
Response
OpenIM usually returns 200 OK when the request reaches the service. Use errCode in the JSON response to determine business success; errCode === 0 means the operation succeeded.
{
"errCode": 0,
"errMsg": "",
"errDlt": ""
}Response fields
| Field | Type | Description |
|---|---|---|
| errCode | int | Business error code. 0 means success. |
| errMsg | string | Short error message. |
| errDlt | string | Detailed error information for troubleshooting. |
Error response
When a request fails, OpenIM returns the same error envelope. See Error codes for the full handling model.
{
"errCode": 1004,
"errMsg": "RecordNotFoundError",
"errDlt": ": [1004]RecordNotFoundError"
}| Scenario | Possible cause | Recommended action |
|---|---|---|
| Authentication failed | token is missing, expired, or not an administrator token. | Issue a new administrator token and keep it on the backend. |
| Traceability is weak | operationID is missing or reused across many requests. | Generate a unique operationID for every request and log it with the response. |
| Validation failed | The request body has an invalid type, missing field, or unsupported enum value. | Compare the payload with the request table and retry after correcting the fields. |
Permissions and limits
- OpenIM marks the user's token for the specified platform as kicked and notifies the gateway to close the corresponding connection.
- The request must use an application administrator token.
- Both
platformIDanduserIDare required.
Related pages
Was this page helpful?