目录

Function

This API is used to request access authorization and obtain an access token so that the app can interact with the Huawei game server within the validity period of the token.

Restrictions

Before calling the API, you need to obtain the client ID and client key used to generate an access token. For details, please refer to Creating an API Client.

Request URL

https://connect-api.cloud.huawei.com/api/oauth2/v1/token

Input Parameters

Parameter

Mandatory (M)/Optional (O)

Type

Description

grant_type

M

String

Access grant type. This parameter has a fixed value of client_credentials.

client_id

M

String

Client ID, that is, the client ID generated in Creating an API Client.

client_secret

M

String

Client key, that is, the key generated in Creating an API Client.

Output Parameters

Parameter

Mandatory (M)/Optional (O)

Type

Description

access_token

M

String

Access token, which follows Authorization: Bearer in the request header sent from the client to the Huawei game server.

expires_in

M

long

Expiration timestamp of the access token.

Example

Type

Example

Request

  1. POST /api/oauth2/v1/token HTTP/1.1
  2. Host: connect-api.cloud.huawei.com
  3. Content-Type: application/json
  4. {
  5.   "grant_type":"client_credentials",
  6.   "client_id":"26********20",
  7.   "client_secret":"************************"
  8. }

Response

  1. HTTP/1.1 200 OK
  2. Content-Type: application/json; charset=utf-8
  3. {
  4.    "access_token": "eyJhbGciOiJIUzU****************,    
  5.    "expires_in": 172800
  6. }