GetAuthCode

Updated at:

Retrieves the connection authorization code and required resource information for an existing image or application creation task.

Operation description

Before calling this operation, you must create a task, and the creation or validation resources corresponding to the task must be available.

  1. Obtain the TaskId and actual TaskType from the response of the task creation operation or GetTask.

  2. Specify ResourceType to obtain the connection information for the creation or validation environment.

  3. Use the returned authorization code together with the user, resource group, and application identifiers in the same response for connection.

The authorization code is a sensitive connection credential. Do not record it in public documents or logs. When specifying AppId, you must also specify the matching AppVersionId.

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

appstreaming:GetAuthCode

none

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

TaskType

string

Yes

The actual task type. It must match the creation or validation task corresponding to the TaskId. Use the TaskType returned by GetTask. The task must also have connectable creation or validation resources. You cannot obtain an authorization code for distribution or snapshot tasks that do not have connection resources. Valid values:

  • AUTO_CREATE_IMAGE_VHD: automatically create a VHD image

  • RETRY_CREATE_IMAGE_VHD: retry VHD image creation

  • AUTO_CREATE_VHD: automatically create a VHD

  • RETRY_VHD: retry VHD creation

  • AUTO_VALIDATE_VHD: automatically validate a VHD

  • RETRY_VALIDATE_VHD: retry VHD validation

  • APPLY_VHD_BUILDER: apply for a VHD application recording environment

  • ADAPT_AUTO: automatically create application adaptation

  • ADAPT_AUTO_RETRY: retry automatic application adaptation creation

  • ADAPT_MANUAL: manually create application adaptation

  • ADAPT_MANUAL_RETRY: retry manual application adaptation creation

  • DESKTOP_CUSTOM_IMAGE: create a custom image for cloud desktop

  • DESKTOP_CUSTOM_IMAGE_RETRY: retry custom image creation for cloud desktop

  • IMAGE_MANUAL: manually create an image

  • IMAGE_MANUAL_RETRY: retry manual image creation

  • IMAGE_FROM_INSTANCE: create an image from an instance

  • IMAGE_FROM_INSTANCE_RETRY: retry image creation from an instance

  • IMAGE_DISTRIBUTE: distribute an image to multiple regions

  • IMAGE_DISTRIBUTE_RETRY: retry image distribution

  • SNAPSHOT_DISTRIBUTE: distribute a snapshot to multiple regions

  • SNAPSHOT_DISTRIBUTE_RETRY: retry snapshot distribution

  • SNAPSHOT_FROM_DISK: create a snapshot from a disk

  • SNAPSHOT_FROM_DISK_RETRY: retry snapshot creation from a disk

IMAGE_MANUAL

ResourceType

string

Yes

The type of the resource to connect to. Valid values:

  • BUILDER: connect to the creation environment

  • VALIDATE: connect to the validation environment

The corresponding environment must be created and in a connectable state.

BUILDER

TaskId

string

Yes

The ID of the existing creation or validation task. Create the task and confirm that the corresponding resources are available before calling this operation.

tid-bp1example****

BizRegionId

string

No

The region compatibility parameter. The destination region of the current connection resource is determined by the execution region of the task. You cannot use this parameter to switch the task region. Omit this parameter.

cn-hangzhou

AppId

string

No

The ID of the application to connect to. When specifying this parameter, you must also provide the matching AppVersionId. If omitted, the application configured in the creation or validation environment is used.

app-bp1example****

AppVersionId

string

No

The ID of the application version to connect to. This parameter is used together with AppId. This parameter is not the image version ID.

apv-bp1example****

Response elements

Element

Type

Description

Example

object

The response to the API call.

Data

object

The business data returned by this operation.

AppId

string

The application ID, used to query the application or unbind the image later.

app-bp1example****

AppInstanceGroupId

string

The delivery group ID of the creation or validation resource. It is used together with the user and application information in this response when connecting.

aig-bp1example****

AuthCode

string

The authorization code used to connect to the creation or validation resource. It is valid for 180 seconds (3 minutes) from the time of issuance. Use it promptly after obtaining it. Use it together with the user, delivery group, and application information in the same response, and keep it confidential as a connection credential.

Do not reuse the authorization code after it is successfully redeemed. If it has been used or has expired, call this operation again to obtain a new one.

e4e169bea1cc48e8afac53**********

UserId

string

The user ID used when connecting to the creation or validation environment. Use the value returned in this response.

__vhd_builder__

RegionId

string

The region ID in this response.

cn-hangzhou

ProductType

string

The purpose type of the connection resource. Valid values:

  • ImageBuilder: image or application creation resource

  • ImageValidate: image or application validation resource

ImageBuilder

AppVersionId

string

The application version ID, used to locate the specified version of the application. This field is not the image version ID.

apv-bp1example****

AccessType

string

The network access type supported by the connection resource. Valid values:

  • INTERNET: supports Internet access

  • VPC: supports VPC access

  • ANY: supports both Internet and VPC access

INTERNET

Success

boolean

Indicates whether the request was processed successfully. true indicates that the request was processed successfully. To check whether an asynchronous task is completed, query the task status separately.

Code

string

The error code. It is returned when the request fails. A successful response may not contain this field.

InternalError

Message

string

The error or result message. It is used to describe the cause when the request fails. A successful response may not contain this field.

Internal error.

RequestId

string

The unique identifier of the request. You can provide this value for troubleshooting.

01A1A962-5503-107B-AC8F-EBA85DF905AC

Examples

Success response

JSON format

{
  "Data": {
    "AppId": "app-bp1example****",
    "AppInstanceGroupId": "aig-bp1example****",
    "AuthCode": "e4e169bea1cc48e8afac53**********",
    "UserId": "__vhd_builder__",
    "RegionId": "cn-hangzhou",
    "ProductType": "ImageBuilder",
    "AppVersionId": "apv-bp1example****",
    "AccessType": "INTERNET"
  },
  "Success": false,
  "Code": "InternalError",
  "Message": "Internal error.",
  "RequestId": "01A1A962-5503-107B-AC8F-EBA85DF905AC"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InternalError Internal error. An internal error occurred.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.