Oauth1.0a授权流程小记

来源:互联网 发布:16年农村淘宝面试流程 编辑:程序博客网 时间:2024/05/22 06:43

Oauth 1.0a 用户授权流程图如下:


A,向服务器端请求未授权的request token

oauth_consumer_key(开发者申请的$appkey)

oauth_signature_method (HMAC-SHA1,RSA-SHA!,PLAINTEXT)

oauth_signature(base64_encode(hash_hmac('sha1', $base_string, $key, true)))

//其中$key为$appsecret."&"(Oauth标准9.2节)

//其中$base_string=(GET|POST|HEAD)."&".urlencode((request uri query string excluded))."&".urlencode(($k."=".urlencode($v)."&")..)

//1,http请求方法名大写;2,请求的baseurl不含参数后urlencode;3,

oauth_timestamp(时间戳)

oauth_nonce(任意随机字符串,不可重复)

oauth_version(optional)

others...

B,服务器返回未授权request token

oauth_token

oauth_token_secret(用于E步骤计算oauth_signature)

oauth_callback_confirmed(true)

C,引导用户去资源存储网站的授权页

oauth_token

D,授权成功,返回授权后的request token

oauth_token(和B步骤返回的oauth_token一样)

oauth_verifier(用于E中换取access token)

E,使用request token换取access token

oauth_consumer_key

oauth_token

oauth_signature_method

oauth_signature(base64_encode(hash_hmac('sha1', $base_string, $key, true)))

//其中$key=$appsecret."&".$token_secret(Oauth标准9.2节)

oauth_timestamp

oauth_nonce

oauth_version(optional)

oauth_verifier

others...

F,返回access token与access token secret

oauth_token(用于受限资源访问)

oauth_token_secret

G,使用access token与access token获取受限资源

oauth_consumer_key

oauth_token

oauth_signature_method

oauth_signature

oauth_timestamp

oauth_nonce

oauth_version(optional)

others...

Oauth规范中把request token以及access token都称作oauth token,上面为了区分就没有统一说明

原创粉丝点击