百度oauth2.0 WEB 链接

Source:http://developer.baidu.com/wiki/index.php?title=docs/oauth/authorization

Webpage  

 

Function : Authorization Code

 

Url: http://openapi.baidu.com/oauth/2.0/authorize

 

Parameters :

1.client_id

2.response_type “code”

3.Redirect_uri if success, then page turn back to this page;(but if user cancel the authorization midway, a string “error=access_denied” would follow  this uri);

4.Display i choose “page”

 

 

Example:

 

http://openapi.baidu.com/oauth/2.0/authorize?

response_type=code

&client_id=yRlmiCbrv56CcjfMwS21DkqP

&redirect_uri=http%3A%2F%2Fwww.lecai.com%2Fuser%2Fbaidu%2Fcallback%2F%3Freferer%3Dhttp%253A%252F%252Fwww.lecai.com%252F%253FagentId%253D4200

&scope=super_msg

&display=page 

 

 

After then , baidu authorization sever build an authorization code and attach it to the Redirect_uri given in parameter before. This just looks like :

Location: http://www.example.com/oauth_redirect?code=ANXxSNjwQDugOnqeikRMu2bKaXCdlLxn

 

Attention:

The validity of each Authorization Code for 10 minutes, and can only be used once.

 

 

Function : via authorization code get access token

 

 Url: https://openapi.baidu.com/oauth/2.0/token

 

Parameters:

1.grant_type: “authorization_code”

2.Code: value of authorization_code

3.Client_id: api key of app(it seems like i have no app)

4.Client_secret: secret key of app  ((*_*))

5.Redirect_uri: same as redirect_uri given before

Example:

https://openapi.baidu.com/oauth/2.0/token?

    grant_type=authorization_code&

    code=ANXxSNjwQDugOnqeikRMu2bKaXCdlLxn&

    client_id=Va5yQRHlA4Fq4eR3LT0vuXV4&

    client_secret=0rDSjzQ20XUj5itV7WRtznPQSzr5pVw2&

    redirect_uri=http%3A%2F%2Fwww.example.com%2Foauth_redirect

+-----------------------------+-----------------+

For Mobile:

 

Example:

http://openapi.baidu.com/oauth/2.0/authorize?

display=mobile&

client_id=yRlmiCbrv56CcjfMwS21DkqP&

response_type=code&

redirect_uri=http%3A%2F%2Fh.lecai.com%2Fapi%2Fcooperator%2Fbaidu%2Flogin%2Fcallback%3Freferer%3DLyNwYXRoPXBhZ2UvbWFpbg%25253D%25253D 

 

posted on 2014-07-28 17:22  13m0n  阅读(1416)  评论(0编辑  收藏  举报