Douban API       laiwei@douban.comhttp://douban.com/people/laiwei          2011-10-29
What is Douban•   Community•   Book•   Movie•   Music•   FM•   AlphaTownExplore Life, Express Youself, Share Lifevia http:...
Why Douban•   50M+ Registered Users•   600+ Cities•   250,000+ Groups•   30000+ Sites•   1000+ Cinemas
Douban APIs•   Miniblog/Shuo•   OpenID•   Books/Movies/Music•   Photos•   Reviews•   Collections•   Notes•   Events•   Rec...
Powered by Douban API• DoubanShuovia http://shuo.douban.com
Powered by Douban API•   Douban FM•   Douban Movie•   Douban Bookcart•   AlphaTown
Powered by Douban API• Third-party Appsvia http://douban.com/service/gallery
Douban Open Platform• OpenID• API
Douban OpenID• 3rd-party sites and applications can let visitors  sign in using their douban id
Inside Douban API• using OAuth 2.0 to access douban APIs• The core concepts are simple:  – Your application asks for a par...
Inside Douban API• Today Douban supports three flows of OAuth  2.0  – The client-side flow for JavaScript applications    ...
Apply Douban Apikeygo to https://www.douban.com/service/auth2/apikey/applythen douban will return a apikey and secret:• ap...
Modify Apikey Propertiesgo tohttps://www.douban.com/service/auth2/apikey/
Client Side Flow1. get access token     GET https://www.douban.com/service/auth2/auth?     client_id=047e255f2309478c0d7a7...
Server Side Flow2 steps to obtain access_token
Server Side Flow1.get authorization codeGET https://www.douban.com/service/auth2/auth?client_id=047e255f2309478c0d7a701d69...
Server Side Flow2. get access_token using the code that first step returnedcurl "https://www.douban.com/service/auth" -H "...
Server Side Flow3. use access_token access APIscurl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14...
Native-application FlowThe same as server side flow
Q&Athanks
Upcoming SlideShare
Loading in …5
×

TechCrunch Hackathon Douban API

3,029 views

Published on

douban api in hackathon 2011 Beijing

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,029
On SlideShare
0
From Embeds
0
Number of Embeds
956
Actions
Shares
0
Downloads
12
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

TechCrunch Hackathon Douban API

  1. 1. Douban API laiwei@douban.comhttp://douban.com/people/laiwei 2011-10-29
  2. 2. What is Douban• Community• Book• Movie• Music• FM• AlphaTownExplore Life, Express Youself, Share Lifevia http://douban.com/about
  3. 3. Why Douban• 50M+ Registered Users• 600+ Cities• 250,000+ Groups• 30000+ Sites• 1000+ Cinemas
  4. 4. Douban APIs• Miniblog/Shuo• OpenID• Books/Movies/Music• Photos• Reviews• Collections• Notes• Events• Recommendations• Tags• Dou-mailvia http://www.douban.com/service/apidoc/reference
  5. 5. Powered by Douban API• DoubanShuovia http://shuo.douban.com
  6. 6. Powered by Douban API• Douban FM• Douban Movie• Douban Bookcart• AlphaTown
  7. 7. Powered by Douban API• Third-party Appsvia http://douban.com/service/gallery
  8. 8. Douban Open Platform• OpenID• API
  9. 9. Douban OpenID• 3rd-party sites and applications can let visitors sign in using their douban id
  10. 10. Inside Douban API• using OAuth 2.0 to access douban APIs• The core concepts are simple: – Your application asks for a particular scope of access – Douban displays an OAuth page to users, asking for consent to authorize access to your application – If the user approves, your application will get a shortlived access token that you can use to validate requests for the users data and a long-lived refresh token.
  11. 11. Inside Douban API• Today Douban supports three flows of OAuth 2.0 – The client-side flow for JavaScript applications running in a browser – The server-side flow for web applications with servers that can securely store persistent information – The native application flow for desktop and mobile applications
  12. 12. Apply Douban Apikeygo to https://www.douban.com/service/auth2/apikey/applythen douban will return a apikey and secret:• apikey="047e255f2309478c0d7a701d691bd6a4"• secret="0253348fa4d10541
  13. 13. Modify Apikey Propertiesgo tohttps://www.douban.com/service/auth2/apikey/
  14. 14. Client Side Flow1. get access token GET https://www.douban.com/service/auth2/auth? client_id=047e255f2309478c0d7a701d691bd6a4& redirect_uri=http://www.douban.com/& response_type=token& scope=shuo_basic_r,shuo_basic_w2. use access_token access api curl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764"
  15. 15. Server Side Flow2 steps to obtain access_token
  16. 16. Server Side Flow1.get authorization codeGET https://www.douban.com/service/auth2/auth?client_id=047e255f2309478c0d7a701d691bd6a4&redirect_uri=http://book.douban.com&response_type=code&scope=shuo_basic_r,shuo_b
  17. 17. Server Side Flow2. get access_token using the code that first step returnedcurl "https://www.douban.com/service/auth" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764" -d "client_id=047e255f2309478c0d7a701d691bd6a4&client_secret=0253348fa4d10541&redirect_uri=http://book.douban.com&grant_type=authorization_code&code=12345"
  18. 18. Server Side Flow3. use access_token access APIscurl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764
  19. 19. Native-application FlowThe same as server side flow
  20. 20. Q&Athanks

×