(未显示2个用户的13个中间版本) | |||
第1行: | 第1行: | ||
− | = | + | =oauth2/access_token= |
− | + | ||
+ | <div class="wiki_txtJ"> | ||
+ | OAuth2 授权第二步 access_token 接口,用 code 换取授权 access_token,该步需在服务端完成 | ||
+ | </div> | ||
+ | |||
==URL== | ==URL== | ||
− | + | ||
+ | https://api.weibo.com/oauth2/access_token | ||
+ | |||
==HTTP请求方式== | ==HTTP请求方式== | ||
+ | |||
POST | POST | ||
+ | |||
+ | |||
==请求参数== | ==请求参数== | ||
{| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color: #CCCCCC;" | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color: #CCCCCC;" | ||
|- | |- | ||
− | !width=" | + | !width="15%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|参数 |
!width="5%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|必选 | !width="5%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|必选 | ||
− | !width=" | + | !width="10%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|类型及范围 |
− | !width=" | + | !width="70%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|说明 |
− | {{api_args|client_id|true|string| | + | {{api_args|client_id|true|string|第三方应用在微博开放平台注册的APPKEY。}} |
− | {{api_args|client_secret|true|string| | + | {{api_args|client_secret|true|string|在微博开放平台注册的应用所对应的AppSecret。}} |
− | {{api_args|grant_type|true|string| | + | {{api_args|grant_type|true|string|请求的类型,需填写 authorization_code。}} |
+ | {{api_args|code|true|string|调用第一步 authorize 接口所获得的授权 code。}} | ||
+ | {{api_args|redirect_uri|true|string|授权回调地址,传的值需与在开放平台网站填写的回调地址一致,设置填写位置:“我的应用>应用信息>高级信息”。}} | ||
|} | |} | ||
− | + | ||
+ | ==返回结果== | ||
+ | |||
+ | <div class="code_type">JSON</div> | ||
+ | <pre class="brush:js"> | ||
+ | { | ||
+ | "access_token": "ACCESS_TOKEN", | ||
+ | "expires_in": "7200", | ||
+ | "remind_in": "7200", | ||
+ | "uid": "1404376560" | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | ==返回字段说明== | ||
+ | |||
{| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color: #CCCCCC;" | {| border="1" cellspacing="0" cellpadding="0" width="100%" class="parameters" style="border-color: #CCCCCC;" | ||
|- | |- | ||
− | !width=" | + | !width="25%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|返回字段 |
− | !width=" | + | !width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型 |
− | !width=" | + | !width="60%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明 |
− | + | {{rdes_args|access_token|string|用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,第三方应用应该对该票据进行校验,校验方法为调用 oauth2/get_token_info 接口,对比返回的授权信息中的APPKEY是否正确一致,然后用 access_token 与自己应用内的用户建立唯一影射关系,来识别登录状态,不能只是简单的使用本返回值里的UID字段来做登录识别。}} | |
− | {{ | + | {{rdes_args|expires_in|string|access_token 的生命周期,单位是秒数。}} |
− | {{ | + | {{rdes_args|uid|string|授权用户的UID,本字段只是为了方便开发者,减少一次 user/show 接口调用而返回的,第三方应用不能用此字段作为用户登录状态的识别,只有 access_token 才是用户授权的唯一票据。}} |
|} | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
+ | {{#a:nobtns|noheading}} | ||
+ | __NOTOC__ |
2022年10月11日 (二) 15:15的最后版本
oauth2/access_token
OAuth2 授权第二步 access_token 接口,用 code 换取授权 access_token,该步需在服务端完成
URL
https://api.weibo.com/oauth2/access_token
HTTP请求方式
POST
请求参数
参数 | 必选 | 类型及范围 | 说明 |
---|---|---|---|
client_id | true | string | 第三方应用在微博开放平台注册的APPKEY。 |
client_secret | true | string | 在微博开放平台注册的应用所对应的AppSecret。 |
grant_type | true | string | 请求的类型,需填写 authorization_code。 |
code | true | string | 调用第一步 authorize 接口所获得的授权 code。 |
redirect_uri | true | string | 授权回调地址,传的值需与在开放平台网站填写的回调地址一致,设置填写位置:“我的应用>应用信息>高级信息”。 |
返回结果
JSON
{ "access_token": "ACCESS_TOKEN", "expires_in": "7200", "remind_in": "7200", "uid": "1404376560" }
返回字段说明
返回字段 | 字段类型 | 字段说明 |
---|---|---|
access_token | string | 用户授权的唯一票据,用于调用微博的开放接口,同时也是第三方应用验证微博用户登录的唯一票据,第三方应用应该对该票据进行校验,校验方法为调用 oauth2/get_token_info 接口,对比返回的授权信息中的APPKEY是否正确一致,然后用 access_token 与自己应用内的用户建立唯一影射关系,来识别登录状态,不能只是简单的使用本返回值里的UID字段来做登录识别。 |
expires_in | string | access_token 的生命周期,单位是秒数。 |
uid | string | 授权用户的UID,本字段只是为了方便开发者,减少一次 user/show 接口调用而返回的,第三方应用不能用此字段作为用户登录状态的识别,只有 access_token 才是用户授权的唯一票据。 |
文档更新时间: 2022-10-11