GetAuthCode

Updated at:

Obtains an authorization code that contains user identity and permission information. You can use this authorization code to invoke cloud applications in integration scenarios.

Operation description

Obtains an authorization code that contains user identity and permission information. You can use this authorization code to invoke cloud applications in integration scenarios.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ecd:GetAuthCode

get

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

ExternalUserId

string

No

The external user ID. This ID is custom-defined by the caller and must be unique within an Alibaba Cloud account. This parameter and EndUserId cannot be both left empty.

alice

EndUserId

string

No

The username of the Wuying convenience account, which must be unique within an Alibaba Cloud account. This parameter and ExternalUserId cannot be both left empty.

alice

Policy

string

No

The access policy that limits the access permissions of the authorization code. If this parameter is left empty, no limits are applied.

Syntax:

{
      "Version": "1",
      "Resource": {
            "Type": "<Resource type>",
            "Id": "<Resource ID>"
      }
}

Valid values for :

  • AppInstanceGroup: delivery group. You can call the ListAppInstanceGroup operation to obtain the ID.

  • AppInstance: application instance. This is a dedicated field.

  • App: application. You can call the ListAppInstanceGroup operation to obtain the ID.

{ "Version": "1", "Resource": { "Type": "AppInstanceGroup", "Id": "aig-9ciijz60n4xsv****" } }

AutoCreateUser

boolean

No

Specifies whether to synchronously create an EndUserId based on ExternalUserId. This parameter takes effect only when EndUserId is left empty.

Valid values:

  • false :

    false: Do not synchronously create. Default value.

  • true :

    true: Synchronously create.

false

TokenType

string

No

The token type. Valid values: LoginToken (logon token) and StsToken (temporary identity credential).

Valid values:

  • StsToken :

    StsToken: temporary identity credential.

  • LoginToken :

    LoginToken: logon token.

StsToken

AccountType

string

No

The account type. Valid values: ad (enterprise AD account) and simple (convenience account).

Valid values:

  • ad :

    ad: enterprise AD account.

  • simple :

    simple: convenience account.

simple

AdDomain

string

No

The Active Directory domain name. This parameter is required when the account type is ad.

AdPassword

string

No

The password of the enterprise AD account.

Response elements

Element

Type

Description

Example

object

The returned information.

RequestId

string

The request ID.

1CBAFFAB-B697-4049-A9B1-67E1FC5F****

AuthModel

object

The authorization code information.

AuthCode

string

The authorization code. The authorization code is valid for 3 minutes and can be used only once regardless of whether the verification succeeds or fails. If multiple authorization codes are generated for a user, only the last generated one is valid.

acv2ZEq2TNSqOlX+DvyetHGRT08iPhbWg/os1W4HojpBxkMQZkAnbKSfz/wNvS0E149IQZ5TogvBUE8ghCSVV+QBnv48Y+sn4z9fY5ywZA1peI5s4TplQI0TADBhPZXEIzMOdmbNsDGGlGcKOAq8ixd1Epzdu9XfvRzdLOO6o3zQwTZxXsjOgGBW8JTcgCP9W9iYiIjHIdZ2VCAnmMzuyVkyED8gymEevH10QoclyH/O3s8Yq6VF34gMXihDQeiI8PyiAZrW0JWXSWpdy3n4yGtAqMAgv46FzTA+XJ6C********

EndUserId

string

The username of the Wuying convenience account.

alice

ExpireTime

string

The expiration time of the authorization code. The time is displayed in UTC and follows the ISO 8601 standard.

2015-01-23T12:33:18Z

Examples

Success response

JSON format

{
  "RequestId": "1CBAFFAB-B697-4049-A9B1-67E1FC5F****",
  "AuthModel": {
    "AuthCode": "acv2ZEq2TNSqOlX+DvyetHGRT08iPhbWg/os1W4HojpBxkMQZkAnbKSfz/wNvS0E149IQZ5TogvBUE8ghCSVV+QBnv48Y+sn4z9fY5ywZA1peI5s4TplQI0TADBhPZXEIzMOdmbNsDGGlGcKOAq8ixd1Epzdu9XfvRzdLOO6o3zQwTZxXsjOgGBW8JTcgCP9W9iYiIjHIdZ2VCAnmMzuyVkyED8gymEevH10QoclyH/O3s8Yq6VF34gMXihDQeiI8PyiAZrW0JWXSWpdy3n4yGtAqMAgv46FzTA+XJ6C********",
    "EndUserId": "alice",
    "ExpireTime": "2015-01-23T12:33:18Z"
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.