All Products
Search
Document Center

Drive and Photo Service:Token

更新時間:Aug 04, 2025

Generates an access token based on Open Authorization (OAuth) 2.0.

Operation description

For more information about how to access Drive and Photo Service from a web server application by using OAuth 2.0, visit OAuth 2.0 For Web Server Applications.

For more information about how to access Drive and Photo Service by using a JSON Web Token (JWT) application, visit Access process for JWT applications.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request syntax

POST /v2/oauth/token HTTP/1.1

Request parameters

ParameterTypeRequiredDescriptionExample
grant_typestringYes

The method that is used to generate an access token. Valid values:

authorization_code: generates an access token by using the authorization code that is returned after the authorization process is complete.

refresh_token: generates an access token by using the refresh token that is returned after the authorization process is complete.

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

refresh_token
codestringNo

The authorization code in the redirect URI that is specified after the authorization process is complete. This parameter is required if grant_type is set to authorization_code.

0045157fa8e24f4f9a0d9e3ff158c1e0
redirect_uristringNo

The redirect URI that is specified when you initiate the authorization request. This parameter is required if grant_type is set to authorization_code.

https://aliyun.com/pds
client_idstringYes

The AppId of the application that is created in the Drive and Photo Service console.

1Zu***flH
client_secretstringNo

The AppSecret of the application that is created in the Drive and Photo Service console. This parameter is required if the application is of the WebServer type.

80D***3i5
refresh_tokenstringNo

The refresh token that is used to refresh the access token. This parameter is required if grant_type is set to refresh_token.

399623e13353490391266c7d48a13ed1
assertionstringNo

The JWT assertion that is signed by using the JWT private key. The JWT assertion contains the information about the user to be authorized and the authorization parameters. For more information about the structure of the JWT assertion, see JWTPayload. This parameter is required if grant_type is set to urn:ietf:params:oauth:grant-type:jwt-bearer.

ey***asd

Response parameters

ParameterTypeDescriptionExample
Token

The information about the access token.

Examples

Sample success responses

JSONformat

{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJjOWI3YTVhYTA0ZDE0YWUzODY3ZmRjODg2ZmEwMWRhNCIsImN1c3RvbUpzb24iOiJ7XCJjbGllbnRJZFwiOlwiMjVkelgzdmJZcWt0Vnh5WFwiLFwiZG9tYWluSWRcIjpcImJqMjlcIixcInNjb3BlXCI6W1wiRFJJVkUuQUxMXCIsXCJTSEFSRS5BTExcIixcIkZJTEUuQUxMXCIsXCJVU0VSLkFMTFwiLFwiVklFVy5BTExcIixcIlNUT1JBR0UuQUxMXCIsXCJTVE9SQUdFRklMRS5MSVNUXCIsXCJCQVRDSFwiLFwiT0FVVEguQUxMXCIsXCJJTUFHRS5BTExcIixcIklOVklURS5BTExcIixcIkFDQ09VTlQuQUxMXCJdLFwicm9sZVwiOlwidXNlclwiLFwicmVmXCI6XCJodHRwczovL3d3dy5hbGl5dW5kcml2ZS5jb20vXCIsXCJkZXZpY2VfaWRcIjpcImIyODIwNWU1YzU5NzRjY2JiODI3MDNiNjhkYjhjNDUxXCJ9IiwiZXhwIjoxNjQ4NjE0NDkzLCJpYXQiOjE2NDg2MDcyMzN9.d3HVLvv_LFw2QhPrhvjH_kICWQJX9sKKt7NjQEqI_xE2JO_b7D8rPsFTZz93PLvZ7MhCmudTjGImUpd-ehFnI4Go-1S7BGaKaHFILvP-sWy18Wpikowjxx9mSbzBM_cO6D1LI-kyYhXKWHgVdADfVIPniTDA7-ffhUpi7cAebEs",
  "refresh_token": "060e78d36afb4879b51e4264e9541c16",
  "expires_in": 3600,
  "token_type": "Bearer",
  "user_id": "DING-xxxxx",
  "user_name": "pdsuser",
  "avatar": "aliyunpds.com/a.jpg",
  "nick_name": "pdsuser",
  "default_drive_id": 1,
  "role": "admin",
  "status": "enabled",
  "expire_time": "2019-09-01T06:57:48.813Z",
  "is_first_login": false,
  "device_id": "8574ecc3d4904dc095cc49202e74db94",
  "device_name": "4683C25F",
  "domain_id": "bj1"
}

Error codes

For a list of error codes, visit the Service error codes.