Help Center/ ServiceStage/ API Reference/ ServiceComb APIs/ Authentication/ Obtaining the User Token of an Exclusive Microservice Engine
Updated on 2024-12-16 GMT+08:00

Obtaining the User Token of an Exclusive Microservice Engine

Function

This API is intended only for exclusive microservice engines with security authentication enabled.

Before accessing APIs of an exclusive microservice engine with security authentication enabled, you need to call this API to obtain a user token. This token is the unique credential for accessing the APIs.

The token must be contained in the request header when an access request is sent. The format is as follows:

Authorization:Bearer{Token}

Restrictions

None

URI

POST /v4/token

Request

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

name

Yes

String

Account name.

password

Yes

String

Password of the account.

Response

Status code: 200

Table 2 Response body parameter

Parameter

Type

Description

token

String

User token, which is valid for 12 hours.

Status code: 401

Table 3 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Status code: 500

Table 4 Response body parameters

Parameter

Type

Description

errorCode

String

Error code.

errorMessage

String

Error message.

detail

String

Location details.

Example Request

POST https://{Service center address}/v4/token

{
    "name": "root",
    "password": "*******"
}

Example Response

Status code: 200

OK

{
  "token" : "****bGciOiJSUzUxMiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50Ijoicm9vdCIsImV4cCI6MTY1MDU5MTcwMSwicm9sZXMiOlsiYWRtaW4iXX0.WKwNAjaYMMCSjNX0qCGCeyh13FJRzLousxoXlThdkMwkH- pXEmG51_SguH0LlHOZoIc8gNJq-ilQg4bxTo1s0pnQZIS3wma0qvE-MzaYnFguTuHM7rxD7eZdwnbUe3dhnw9xRqR1hcd-lTuBbLoL9fbED4U_63IoEDyBCJl9D_l0F86uGzpUysCvC-t6MrJHgi7miUaO7ZZQmSAUNhmbEoN8IIVp-QtP_cWNWtWaFO-eoQrmCT2FdlYiB9MCuELr9-5EGM_mFLPgs6E4fyIGiGHy7IwoGUKOCW5w6Jb0l-2JxeUe3eOl5Md5kzOIAE_EYUATxCbJ5GmgpSSJf*****"
}

Status Code

Status Code

Description

200

OK

401

Unauthorized

500

Internal Server Error

Error Code

See ServiceComb Error Codes.