Obtain a token from a carrier

Updated at:

This topic describes how to obtain a token from the three major carriers in China and describes the interaction flow.

Interaction flow

The following figure shows the process for China Mobile, China Unicom, and China Telecom users to obtain a token.

1d37180f4842dab38b6d7c3a4c05c0c4.png

Token acquisition methods

Obtaining a token for mobile users

Communication protocol

Method

Access address

HTTPS+application/Json

POST

https://msg.cmpassport.com/h5/getMobile

Request parameters

Parameter

Description

Sample value

traceId

The external serial number. This must be the same as the value of the OutId input parameter for the GetUAIDApplyTokenSign operation.

mfawsxtcmyplwzpayzzvdvbsowxmkynr

appId

Use 300012406312.

300012406312

sign

Obtain this by calling the GetUAIDApplyTokenSign operation.

2c61b3c58ffbeed97461e31be4fd931a

msgId

The external serial number. This must be the same as the value of the OutId input parameter for the GetUAIDApplyTokenSign operation.

redbyxsdetddwaaffajcwwapspykftzx

businessType

Use 3.

3

version

Use 1.0.

1.0

timestamp

The system time when the request message is sent, accurate to the millisecond. This must be the same as the value and format of the Time input parameter for the GetUAIDApplyTokenSign operation.

20201125101540980

Response parameters

Parameter

Description

Example

appId

Corresponds to the AppId in the request message.

300012406312

msgId

Corresponds to the msgId in the request message.

redbyxsdetddwaaffajcwwapspykftzx

timestamp

The system time when the response message is sent.

20201125101607932

resultCode

The return code of the API.

103000

resultDesc

Process Status Code

Success

token

Returned on success. The identity.

H5HTTPS4187AE9743AFCB14F8D99B9D65ED9E01

Obtain a token for China Unicom users

For China Unicom users, obtaining a token is a two-step process. The API supports calls in JSON and JSONP formats.

Step 1: Obtain the authentication server address

Communication protocol

Method

Access address

HTTPS + application/Json

GET

https://nisportal.10010.com:9001/api

Request parameters

Parameter

Description

Example

appid

Use 1554778161153.

1554778161153

callback

The name of the JSONP callback function. This parameter is required only when you use the jsonp format.

callbackFunction

Response parameters

Parameter name

Description

Example

authurl

The authentication server address.

https://enrichgw.10010.com/d93222629f52ec79

Step 2: Obtain the token

Communication protocol

Method

Access address

HTTPS + application/Json

GET

${authurl}+"/api"

Request parameters

Parameter name

Description

Example

appid

Use 1554778161153.

1554778161153

callback

The name of the JSONP callback function. This parameter is required only when you use the jsonp format.

callbackFunction

Response parameters

Parameter name

Description

Example

province

The province ID.

1

code

The authentication code. A 32-character string.

7nHS1nggx2WP613750206700RN6oiRN1

The value of the code parameter is the token.

Obtain a token for China Telecom users

Communication protocol

Method

Access address

HTTPS+application/x-www-form-urlencoded;

charset=UTF-8

GET

https://id6.me/gw/preuniq.do

Request parameters

Parameter Name

Description

Example

clientType

The client type. This must be the same as the value of the ClientType input parameter for the GetUAIDApplyTokenSign operation. Enumeration values:

  • Android: 30100

  • iOS: 30300

  • H5: 20200

  • WEB: 10010

30100

appId

Use 9390188202.

9390188202

format

The request format. This must be the same as the value of the Format input parameter for the GetUAIDApplyTokenSign operation. Enumeration values:

  • json

  • jsonp

jsonp

sign

Obtain this by calling the GetUAIDApplyTokenSign operation.

D63C166FA19E1996EF********09C6A5397C10B4

paramKey

  • The ciphertext of key A. Key A is a 16-character random string generated by the access client. paramKey = RSA1024("${Key A}", "${China Telecom Account Platform Public Key}"). The padding pattern is RSA/ECB/PKCS1Padding. Download the China Telecom RSA public key.

paramKey=1D7C25EB8B0B8B4CB3CF8DC60628F6549********786B0AF1FEF93FA1335057A35BF5F0B39A3867EAA9BE14B3898********8B01DE34965060445B6E1F66401D714650E4AB161CD6DCF4A72********3B856F22A192B8B0C39D7A55B961062E68C89C928894F119B25********7C548355FE9DB82852EB93C939F2200B48CD17

paramStr

The ciphertext of the private request parameters. paramStr = AES("timeStamp=${timeStamp}&callback=${callback}", "${Key A}"). The padding pattern is AES/CBC/PKCS5Padding, and the initialization vector is 0000000000000000.

  • timeStamp is a timestamp accurate to the millisecond. It corresponds to the value of the Time input parameter for the GetUAIDApplyTokenSign operation, but the format is different. Example: 1697791988302.

  • callback is the callback method used for the jsonp format. This is required only when format is set to jsonp.

140********95AF8E138B94754CB4CF83BA6FB********52B258BFDFD38BF233

version

Use 1.1.

1.1

Response parameters

Parameter

Description

Example

result

10000

msg

success

data

The encrypted response data. data = AES(Response Result, Key A). Use Key A to perform AES decryption (AES/CBC/PKCS5Padding).

a35336711c70456cb883f4f224e9a259

accessCode

The decrypted response data. Obtain the value of accessCode.

H5HTTPS4187AE9743AFCB14F8D99B9D65ED9E01