com.belerweb.social.weibo.api
Class OAuth2

java.lang.Object
  extended by com.belerweb.social.API
      extended by com.belerweb.social.weibo.api.OAuth2

public final class OAuth2
extends API


Field Summary
 
Fields inherited from class com.belerweb.social.API
connect, t, weibo, weixin
 
Method Summary
 Result<AccessToken> accessToken(String code)
          从 Weibo 从获取clientId,clientSecret,grantType,redirectUri 使用 authorization_code
 Result<AccessToken> accessToken(String code, String redirectUri)
          从 Weibo 从获取clientId,clientSecret,grantType 使用 authorization_code
 Result<AccessToken> accessToken(String clientId, String clientSecret, String grantType, String code, String redirectUri)
          OAuth2的access_token接口 文档地址:http://open.weibo.com/wiki/OAuth2/access_token
 String authorize()
          OAuth2的authorize接口 从 Weibo 从获取clientId,redirectUri,scope 使用 Scope.ALL,其余参数默认
 String authorize(String redirectUri)
          OAuth2的authorize接口 从 Weibo 从获取clientId,scope 使用 Scope.ALL,其余参数默认
 String authorize(String clientId, String redirectUri, Scope[] scope, String state, Display display, Boolean forceLogin, String language)
          OAuth2的authorize接口 文档地址:http://open.weibo.com/wiki/Oauth2/authorize
 void getOAuth2Token(String oauthConsumerKey, String oauthToken, String oauthSignatureMethod, Long oauthTimestamp, String oauthNonce, String oauthVersion, String oauthSignature)
          用于OAuth1.0 access token 更换至 OAuth2.0 access token,帮助开发者使用新版接口和OAuth2.0时平滑迁移用户。详细的OAuth1.0调用方式和SDK资源参见:http://open.weibo.com/wiki/Oauth 文档地址:http://open.weibo.com/wiki/Oauth2/get_oauth2_token
 Result<TokenInfo> getTokenInfo(String accessToken)
          查询用户access_token的授权相关信息,包括授权时间,过期时间和scope权限。 文档地址:http://open.weibo.com/wiki/Oauth2/get_token_info
 Result<Boolean> revokeOAuth2(String accessToken)
          授权回收接口,帮助开发者主动取消用户的授权。 文档地址:http://open.weibo.com/wiki/Oauth2/revokeoauth2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

authorize

public String authorize()
OAuth2的authorize接口 从 Weibo 从获取clientId,redirectUri,scope 使用 Scope.ALL,其余参数默认

See Also:
authorize(String, String, Scope[], String, Display, Boolean, String)

authorize

public String authorize(String redirectUri)
OAuth2的authorize接口 从 Weibo 从获取clientId,scope 使用 Scope.ALL,其余参数默认

Parameters:
redirectUri - 授权回调地址,站外应用需与设置的回调地址一致,站内应用需填写canvas page的地址。
See Also:
authorize(String, String, Scope[], String, Display, Boolean, String)

authorize

public String authorize(String clientId,
                        String redirectUri,
                        Scope[] scope,
                        String state,
                        Display display,
                        Boolean forceLogin,
                        String language)
OAuth2的authorize接口 文档地址:http://open.weibo.com/wiki/Oauth2/authorize

Parameters:
clientId - 申请应用时分配的AppKey。
redirectUri - 授权回调地址,站外应用需与设置的回调地址一致,站内应用需填写canvas page的地址。
scope - 申请scope权限所需参数,可一次申请多个scope权限,用逗号分隔。使用文档
state - 用于保持请求和回调的状态,在回调时,会在Query Parameter中回传该参数。开发者可以用这个参数验证请求有效性,也可以记录用户请求授权页前的位置。这个参数可用于防止跨站请求伪造(CSRF)攻击
display - 授权页面的终端类型,取值见下面的说明。
forceLogin - 是否强制用户重新登录,true:是,false:否。默认false。
language - 授权页语言,缺省为中文简体版,en为英文版。

accessToken

public Result<AccessToken> accessToken(String code)
Weibo 从获取clientId,clientSecret,grantType,redirectUri 使用 authorization_code

See Also:
accessToken(String, String, String, String, String)

accessToken

public Result<AccessToken> accessToken(String code,
                                       String redirectUri)
Weibo 从获取clientId,clientSecret,grantType 使用 authorization_code

See Also:
accessToken(String, String, String, String, String)

accessToken

public Result<AccessToken> accessToken(String clientId,
                                       String clientSecret,
                                       String grantType,
                                       String code,
                                       String redirectUri)
OAuth2的access_token接口 文档地址:http://open.weibo.com/wiki/OAuth2/access_token

Parameters:
clientId - 申请应用时分配的AppKey。
clientSecret - 申请应用时分配的AppSecret。
grantType - 请求的类型,填写authorization_code
code - grant_type为authorization_code时,调用authorize获得的code值。
redirectUri - grant_type为authorization_code时,回调地址,需需与注册应用里的回调地址一致。

getTokenInfo

public Result<TokenInfo> getTokenInfo(String accessToken)
查询用户access_token的授权相关信息,包括授权时间,过期时间和scope权限。 文档地址:http://open.weibo.com/wiki/Oauth2/get_token_info

Parameters:
accessToken - 用户授权时生成的access_token。

getOAuth2Token

public void getOAuth2Token(String oauthConsumerKey,
                           String oauthToken,
                           String oauthSignatureMethod,
                           Long oauthTimestamp,
                           String oauthNonce,
                           String oauthVersion,
                           String oauthSignature)
用于OAuth1.0 access token 更换至 OAuth2.0 access token,帮助开发者使用新版接口和OAuth2.0时平滑迁移用户。详细的OAuth1.0调用方式和SDK资源参见:http://open.weibo.com/wiki/Oauth 文档地址:http://open.weibo.com/wiki/Oauth2/get_oauth2_token

Parameters:
oauthConsumerKey - 创建应用时生成的APP KEY。
oauthToken - oauth的token。
oauthSignatureMethod - 签名方法,建议使用“HMAC-SHA1”。
oauthTimestamp - 生成Base String时的时间戳。
oauthNonce - 单次值,一个随机字符串,防止重复攻击。该参数只支持ASCII码的字符串。
oauthVersion - OAuth协议版本。填写“1.0”。
oauthSignature - 签名值,是由根据上面的几个参数生成的 Base String经HMAC-SHA1算法计算得出。

revokeOAuth2

public Result<Boolean> revokeOAuth2(String accessToken)
授权回收接口,帮助开发者主动取消用户的授权。 文档地址:http://open.weibo.com/wiki/Oauth2/revokeoauth2

Parameters:
accessToken - 用户授权应用的access_token


Copyright © 2014. All Rights Reserved.