Get a token using a secret
Brief Description
- Obtain a user token or APP administrator token
⚠️ Note: OpenIM Server has a APP administrators, his userID
is imAdmin
:
Request Method
post
Request URL
{API_ADDRESS}/auth/user_token
Header
Header Name | Example Value | Optional | Type | Description |
---|---|---|---|---|
operationID | 1646445464564 | Required | string | operationID is used for global link tracking |
Request Sample Parameters
{
"secret": "openIM123",
"platformID": 1,
"userID": "111111"
}
Field Name | Optional | Type | Description |
---|---|---|---|
secret | Required | string | openIM secret, see the secret field in config/config.yaml |
platformID | Required | int | Platform ID: 1: IOS, 2: Android, 3: Windows, 4: OSX, 5: Web, 6: MiniWeb, 7: Linux, 8: Android Pad, 9: IPad, 10: admin |
userID | Required | string | Regular userID or administrator userID, such as when generating an administrator token, you need to enter openIMAdmin . |
Successful Return Sample
{
"errCode": 0,
"errMsg": "",
"errDlt": "",
"data": {
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiJvcGVuSU1BZG1pbiIsIlBsYXRmb3JtSUQiOjEsImV4cCI6MTY5Njc1NDgwNSwibmJmIjoxNjg4OTc4NTA1LCJpYXQiOjE2ODg5Nzg4MDV9.SAu86X3PzfYjtjBeYA4vZefNr1IiFKRgg12FeiXSm14",
"expireTimeSeconds": 7776000
}
}
Successful Return Sample Explanation
Parameter Name | Type | Description |
---|---|---|
errCode | int | Error code, 0 indicates success |
errMsg | string | Brief error message, empty when no error |
errDlt | errDlt | Detailed error message, empty when no error |
data | object | General data object, the specific structure is shown below |
token | string | Acquired user token |
expireTimeSeconds | string | Token expiration time (in seconds) |
Failed Return Sample
{
"errCode": 1004,
"errMsg": "RecordNotFoundError",
"errDlt": ": [1004]RecordNotFoundError"
}
Failed Return Sample Explanation
Parameter Name | Type | Description |
---|---|---|
errCode | int | Error code, refer to the global error code document |
errMsg | string | Brief error message |
errDlt | errDlt | Detailed error message |