Oauth2/authorize

跳转到: 导航, 搜索
第26行: 第26行:
 
{| 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="30%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数取值
+
!width="20%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|参数取值
!width="70%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|类型说明
+
!width="80%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|类型说明
 
|-
 
|-
 
|style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|default
 
|style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|default
第55行: 第55行:
 
{| 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="10%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"| 
+
!width="25%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|返回值字段
!width="5%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|必选
+
!width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型
!width="20%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|类型及范围
+
!width="60%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明
!width="65%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|说明
+
{{rdes_args|code|string|用于调用access_token,接口获取授权后的access token。}}
{{api_args|code |true|string|用于调用access_token接口获取授权后的access token}}
+
{{rdes_args|state|string|如果传递参数,会回传该参数。}}
{{api_args|state|false|string|如果传递参数,会回传该参数}}
+
 
|}
 
|}
  
第67行: 第66行:
 
{| 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="10%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"| 
+
!width="25%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|返回值字段
!width="5%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|必选
+
!width="15%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段类型
!width="20%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|类型及范围
+
!width="60%" style="text-align:left;padding-left:5px;font-weight:bolder;border:1px solid #cccccc"|字段说明
!width="65%" style="text-align:center;font-weight:bolder;border:1px solid #cccccc"|说明
+
{{rdes_args|access_token|string|用来调用其它接口的授权过的accesstoken。}}
{{api_args|access_token|true|string|用来调用其它api的授权过的accesstoken}}
+
{{rdes_args|expires_in|string|accesstoken有效期时间,unix的timestamp格式。}}
{{api_args|expires_in|true|string|accesstoken有效期时间,unix timestamp格式}}
+
{{rdes_args|refresh_token|string|刷新token,如果有获取权限则返回。}}
{{api_args|refresh_token|false|string|刷新token,如果有获取权限则返回}}
+
{{rdes_args|state|string|如果传递参数,会回传该参数。}}
{{api_args|state|false|string|如果传递参数,会回传该参数}}
+
 
|}
 
|}
  
 
==示例==
 
==示例==
 
;'''response_type为token'''
 
;'''response_type为token'''
:请求
+
<pre>
:https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=token
+
//请求
:同意授权后会重定向
+
https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=token
:http://www.example.com/response#access_token=ACCESS_TOKEN&expires_in=250327040&refresh_token=REFRESH_TOKEN
+
  
 +
//同意授权后会重定向
 +
http://www.example.com/response#access_token=ACCESS_TOKEN&expires_in=250327040&refresh_token=REFRESH_TOKEN
 +
</pre>
  
 
;'''response_type为code'''
 
;'''response_type为code'''
:请求
+
<pre>
:https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=code
+
//请求
:同意授权后会重定向
+
https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=code
:http://www.example.com/response&code=CODE
+
 
 +
//同意授权后会重定向
 +
http://www.example.com/response&code=CODE
 +
</pre>
  
  
  
 
__NOTOC__
 
__NOTOC__

2011年12月9日 (五) 15:11的版本

oauth2/authorize

OAuth2的authorize接口

URL

https://api.weibo.com/oauth2/authorize

HTTP请求方式

GET/POST

请求参数

  必选 类型及范围 说明
client_id true string 申请应用时分配的AppKey。
redirect_uri true string 授权后的回调地址,站外应用需与设置的回调地址一致,站内应用需填写canvas page的地址。
response_type false string 返回类型,支持code、token,默认值为code。
state false string 用于保持请求和回调的状态,在回调时,会在Query Parameter中回传该参数。
display false string 授权页面的终端类型,取值见下面的说明。


display说明:
参数取值 类型说明
default 默认的授权页面,适用于web浏览器。
mobile 移动终端的授权页面,适用于支持html5的手机。
popup 弹窗类型的授权页,适用于web浏览器小窗口。
wap1.2 wap1.2的授权页面。
wap2.0 wap2.0的授权页面。
js 微博JS-SDK专用授权页面,弹窗类型,返回结果为JSONP回掉函数。
apponweibo 站内应用专用,站内应用不传display参数,并且response_type为token时,默认使用该类型,授权后不返回access_token,只刷新站内应用父框架。

返回数据

response_type为code
返回值字段 字段类型 字段说明
code string 用于调用access_token,接口获取授权后的access token。
state string 如果传递参数,会回传该参数。


response_type为token
返回值字段 字段类型 字段说明
access_token string 用来调用其它接口的授权过的accesstoken。
expires_in string accesstoken有效期时间,unix的timestamp格式。
refresh_token string 刷新token,如果有获取权限则返回。
state string 如果传递参数,会回传该参数。

示例

response_type为token
//请求
https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=token

//同意授权后会重定向
http://www.example.com/response#access_token=ACCESS_TOKEN&expires_in=250327040&refresh_token=REFRESH_TOKEN
response_type为code
//请求
https://api.t.sina.com.cn/oauth2/authorize?client_id=123050457758183&redirect_uri=http://www.example.com/response&response_type=code

//同意授权后会重定向
http://www.example.com/response&code=CODE