GenerateJWTUserToken - Generate a token for a JWT identity source

更新时间:
复制 MD 格式

This topic describes the authorization, request and response parameters, and error codes for the GenerateNativeUserToken API.

Authorization information

The following table lists the authorization information for this API. You can add this information to the Action element of a RAM access policy statement to grant a RAM user or RAM role the permissions to call this API.

  • Operation: The specific permission.

  • Resource Type: The type of resource that the operation can be authorized on.

    • Required resource types are highlighted.

    • If an operation does not support resource-level authorization, this is indicated by All Resources.

  • Condition Key: A condition key defined by the cloud product.

  • Associated Operation: Other permissions required for the operation to succeed. The caller must also have permissions for the associated operations.

Operation

Resource type

Condition key

Associated operation

mobilcdpdev:GenerateNativeUserToken

All resources

None

None

Warning

If a RAM user calls this API, you must first enable the required RAM permissions for Mobi. Then, contact the administrator of the Alibaba Cloud account to add the RAM user as a member of the workspace.

Request parameters

Name

Type

Required

Description

Example

WorkspaceId

string

Yes

The workspace ID.

171706276418746

Username

string

Yes

The username. This is the unique identifier for a user within the workspace.

user_test

PhoneNumber

string

No

The user's phone number.

137****2208

Email

string

No

The user's email address.

email@example.com

Nickname

string

No

The user's nickname.

test

Picture

string

No

The user's profile picture.

https://picture.example

PermissionGroupName

string

No

The permission group to which the user is added.

HR_GROUP1

Note

If a default permission group is configured in the JSON Web Token (JWT) identity source and you specify a different permission group in the API call, the user is added to both permission groups.

Response parameters

Name

Type

Description

Sample value

AccessToken

string

The access token for the Mobi user.

eyJhbGciOiJIUzUxMiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI4O***

ExpiresIn

integer

The time-to-live (TTL) of the access token, in seconds.

300

RefreshToken

string

The refresh token for the Mobi user.

eyJhbGciOiJIUzUxMiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICI4O***

RefreshExpiresIn

integer

The TTL of the refresh token, in seconds.

300

TokenType

string

The token type.

Bearer

Scope

string

The scope included in the access token.

profile

Examples

Example of a successful response

{
	"RequestId": "97AB1310****CF7687B0C0A7",
	"Data": {
		"ExpiresIn": 300,
		"TokenType": "Bearer",
		"RefreshToken": "eyJhbGciOiJIUzUxMiIsInR***",
		"AccessToken": "eyJhbGciOiJSUzI1NiI***",
		"RefreshExpiresIn": 1800
	}
}

Error codes

HTTP status code

Error code

Error message

Description

400

NativeIdentityProvider.NotExists

The JWT identity source does not exist.

Create a JWT identity source in the Mobi workspace.

400

NativeIdentityProvider.NotEnabled

The JWT identity source is not enabled.

Enable the JWT identity source in the Mobi workspace.

400

User.NoPermission

Permission denied.

You do not have access permissions for the workspace.

400

Group.NotFound

The permission group does not exist.

The specified permission group does not exist in the current workspace.