Updated on 2025-11-06 GMT+08:00

Modifying the Token Policy of an Account

Function

This API is used to modify the token policy of an account. The token policy controls whether tokens can be obtained for IAM users, agencies, and federated users under the account. (Unscoped tokens obtained through federated authentication are not affected).

Authorization Information

No identity policy-based permission required for calling this API.

URI

PUT /v5/token-policy

Request Parameters

Table 1 Request body parameters

Parameter

Mandatory

Type

Description

token_enabled

No

Boolean

Whether obtaining tokens is allowed. The default value is true. Setting this parameter to false forbids token obtaining for IAM users, agencies, and federated users under the account. (Unscoped tokens obtained through federated authentication are not affected.)

Response Parameters

Status code: 200

Table 2 Response body parameters

Parameter

Type

Description

token_policy

TokenPolicy object

Token policy of an account.

Table 3 TokenPolicy

Parameter

Type

Description

token_enabled

Boolean

Whether obtaining tokens is allowed. The default value is true. Setting this parameter to false forbids token obtaining for IAM users, agencies, and federated users under the account. (Unscoped tokens obtained through federated authentication are not affected.)

Status code: 400

Table 4 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

Status code: 403

Table 5 Response body parameters

Parameter

Type

Description

error_code

String

Error code.

error_msg

String

Error message.

request_id

String

Request ID.

encoded_authorization_message

String

Encrypted authentication failure information, which can be decrypted using the STS5 decryption API.

Example Requests

Modifying the token policy of an account

PUT https://{endpoint}/v5/token-policy

{
  "token_enabled" : true
}

Example Responses

Status code: 200

Request succeeded.

{
  "token_policy" : {
    "token_enabled" : true
  }
}

Status Codes

Status Code

Description

200

Request succeeded.

400

Abnormal request body.

403

Insufficient permissions.

Error Codes

See Error Codes.