Skip to main content

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 NameExample ValueOptionalTypeDescription
operationID1646445464564RequiredstringoperationID is used for global link tracking

Request Sample Parameters

{
"secret": "openIM123",
"platformID": 1,
"userID": "111111"
}
Field NameOptionalTypeDescription
secretRequiredstringopenIM secret, see the secret field in config/config.yaml
platformIDRequiredintPlatform ID: 1: IOS, 2: Android, 3: Windows, 4: OSX, 5: Web, 6: MiniWeb, 7: Linux, 8: Android Pad, 9: IPad, 10: admin
userIDRequiredstringRegular 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 NameTypeDescription
errCodeintError code, 0 indicates success
errMsgstringBrief error message, empty when no error
errDlterrDltDetailed error message, empty when no error
dataobjectGeneral data object, the specific structure is shown below
tokenstringAcquired user token
expireTimeSecondsstringToken expiration time (in seconds)

Failed Return Sample

{
"errCode": 1004,
"errMsg": "RecordNotFoundError",
"errDlt": ": [1004]RecordNotFoundError"
}

Failed Return Sample Explanation

Parameter NameTypeDescription
errCodeintError code, refer to the global error code document
errMsgstringBrief error message
errDlterrDltDetailed error message