All Products
Search
Document Center

Drive and Photo Service:Token

Last Updated:May 28, 2026

Obtains an access token as part of the OAuth 2.0 authorization flow.

Operation description

For more information, see the user guide.

For details on JWT-based logon, see JWT-based logon.

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

No authorization for this operation. If you encounter issues with this operation, contact technical support.

Request syntax

POST /v2/oauth/token HTTP/1.1

Request parameters

Parameter

Type

Required

Description

Example

domain_id

string

Yes

grant_type

string

Yes

The grant type. Valid values:

authorization_code: Exchanges an authorization code, returned after successful authentication, for an access token.

refresh_token: Uses a refresh token from a previous authorization to obtain a new access token.

urn:ietf:params:oauth:grant-type:jwt-bearer: Obtains an access token by using a JWT.

refresh_token

code

string

No

The authorization code returned in the redirect URI after successful authentication. This parameter is required when grant_type is authorization_code.

0045157fa8e24f4f9a0d9e3ff158c1e0

redirect_uri

string

No

The redirect URI used in the authorization request. This parameter is required when grant_type is authorization_code.

https://aliyun.com/pds

client_id

string

Yes

The ID of the app you create in the Alibaba Cloud PDS console.

1Zu***flH

client_secret

string

No

The secret of the app you create in the Alibaba Cloud PDS console. This parameter is required for WebServer applications.

80D***3i5

refresh_token

string

No

The token used to refresh an access token. This parameter is required when grant_type is refresh_token.

399623e13353490391266c7d48a13ed1

assertion

string

No

A JWT-signed string that contains user information and authorization parameters to be granted. For the structure, see JWTPayload. This parameter is required when grant_type is urn:ietf:params:oauth:grant-type:jwt-bearer.

ey***asd

Response elements

Element

Type

Description

Example

Token

Contains details about the access token.

Examples

Success response

JSON format

{
  "access_token": "",
  "refresh_token": "",
  "expires_in": 0,
  "token_type": "",
  "user_id": "",
  "user_name": "",
  "avatar": "",
  "nick_name": "",
  "default_drive_id": "",
  "role": "",
  "status": "",
  "expire_time": "",
  "is_first_login": true,
  "device_id": "",
  "device_name": "",
  "domain_id": "",
  "default_sbox_drive_id": "",
  "user_data": {
    "key": ""
  },
  "pin_setup": true,
  "need_rp_verify": true,
  "state": "",
  "exist_link": [
    {
      "type": "",
      "identity": "",
      "extra": ""
    }
  ],
  "need_link": true
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.