oauth.token (Exchange authorization access tokens)
Common request parameters
None.
Business request parameters
|
Parameter |
Required |
Field length |
Description |
Example value |
|
grant_type |
Yes |
string[1,20] |
Authorization type.
|
authorization_code |
|
code |
Optional |
string[0,40] |
Authorization code obtained after the user authorizes the application. Note
Required when grant_type is authorization_code. Do not set when grant_type is refresh_token. |
xxx |
|
refresh_token |
Optional |
string[0,40] |
Refresh token obtained from the previous token exchange. Note
Do not set when grant_type is authorization_code. Required when grant_type is refresh_token. The value comes from the app_refresh_token field returned by a prior call to this API with grant_type=authorization_code. |
xxx |
Common request example
curl 'https://xxxx?charset=UTF-8&method=oauth.token&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \
-F 'refresh_token=xxx' \
-F 'code=xxxxx' \
-F 'grant_type=authorization_code'
This example is for reference only.
Common response parameters
None.
Business response parameters
|
Parameter |
Required |
Field length |
Description |
Example value |
|
access_token |
Yes |
string(40) |
Access token for calling authorized APIs. |
xxxxx |
|
expires_in |
Yes |
string(16) |
Access token validity period, in seconds. |
3600 |
|
refresh_token |
Yes |
string(40) |
Refresh token for renewing the access_token. |
xxxx |
|
re_expires_in |
Yes |
string(16) |
Refresh token validity period, in seconds. |
3600 |
|
user_id |
Either user_id or open_id is required |
string(16) |
User ID. |
xxxxx |
|
open_id |
Either user_id or open_id is required |
string(128) |
User open ID. |
xxxx |
|
auth_start |
Optional |
date(32) |
Authorization token start time, used as the baseline for calculating validity. |
2010-11-11 11:11:11 |
Response example
{
"oauth_token_response": {
"user_id": "xxx",
"open_id": "xxxx",
"access_token": "xxxxxx",
"expires_in": "3600",
"refresh_token": "xxxxxxx",
"re_expires_in": "3600",
"auth_start": "2010-11-11 11:11:11"
},
"sign": "xxxxx"
}
This example is for reference only.
user.info.share (Query member authorization information)
Queries authorized member information. Use with the member authorization API.
Common request parameters
None.
Business request parameters
None.
Common request example
curl 'https://xx?charset=UTF-8&method=user.info.share&format=json&sign=${sign}&app_id=${appid}&version=1.0&sign_type=RSA2×tamp=${now}' \
-F 'app_auth_token=${app_auth_token}' \
-F 'auth_token=${auth_token}'
This example is for reference only.
Common response parameters
None.
Business response parameters
|
Parameter |
Required |
Field length |
Description |
Example value |
|
avatar |
Yes |
string(400) |
User profile picture URL. Important
Not returned if the user has not set a profile picture. Handle this case in your code. |
- |
|
city |
Yes |
string(20) |
City. |
Shanghai |
|
nick_name |
Yes |
string(50) |
User nickname. Important
Not returned if the user has not set a nickname. Handle this case in your code. |
Xiao Er |
|
province |
Yes |
string(20) |
Province. |
Anhui |
|
user_id |
Either user_id or open_id is required |
string(16) |
User ID. |
2088102104794936 |
|
open_id |
Either user_id or open_id is required |
string(128) |
User open ID. |
xxxxxx |
|
gender |
Optional |
string(10) |
Gender. Valid values:
|
F |
Response example
{
"user_info_share_response": {
"code": "10000",
"msg": "Success",
"user_id": "xxxxxx",
"avatar": "",
"city": "Anqing",
"nick_name": "Xiao Er",
"province": "Anhui",
"gender": "F"
},
"sign": "xxxxxxx"
}
This example is for reference only.