SlideShare ist ein Scribd-Unternehmen logo
1 von 20
Douban API

       laiwei@douban.com
http://douban.com/people/laiwei

          2011-10-29
What is Douban
•   Community
•   Book
•   Movie
•   Music
•   FM
•   AlphaTown

Explore Life, Express Youself, Share Life

via http://douban.com/about
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
•   Recommendations
•   Tags
•   Dou-mail

via http://www.douban.com/service/apidoc/reference
Powered by Douban API
• DoubanShuo




via http://shuo.douban.com
Powered by Douban API
•   Douban FM
•   Douban Movie
•   Douban Bookcart
•   AlphaTown
Powered by Douban API
• Third-party Apps




via 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 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
    user's data and a long-lived refresh token.
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
Apply Douban Apikey
go to https://www.douban.com/service/auth2/apikey/apply

then douban will return a apikey and secret:

• apikey="047e255f2309478c0d7a701d691bd6a4"
• secret="0253348fa4d10541
Modify Apikey Properties
go to
https://www.douban.com/service/auth2/apikey/
Client Side Flow
1. 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_w

2.   use access_token access api
     curl "https://api.douban.com/people/@me" 
     -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764"
Server Side Flow

2 steps to obtain access_token
Server Side Flow

1.get authorization code
GET 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
Server Side Flow

2. get access_token using the code
 that first step returned
curl "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"
Server Side Flow

3. use access_token access APIs
curl "https://api.douban.com/people/@me" 
-H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764
Native-application Flow

The same as server side flow
Q&A

thanks

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (9)

A 4 line login - line platform
A 4 line login - line platformA 4 line login - line platform
A 4 line login - line platform
 
Spring4 security oauth2
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
 
OAuth2 Authentication
OAuth2 AuthenticationOAuth2 Authentication
OAuth2 Authentication
 
KKBOX WWDC17 Notification and Autolayout - Jefferey
KKBOX WWDC17 Notification and Autolayout - JeffereyKKBOX WWDC17 Notification and Autolayout - Jefferey
KKBOX WWDC17 Notification and Autolayout - Jefferey
 
Spring4 security oauth2
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
 
Security for oauth 2.0 - @topavankumarj
Security for oauth 2.0 - @topavankumarjSecurity for oauth 2.0 - @topavankumarj
Security for oauth 2.0 - @topavankumarj
 
KKBOX WWDC17 UIKit Drag and Drop - Mario
KKBOX WWDC17  UIKit Drag and Drop - MarioKKBOX WWDC17  UIKit Drag and Drop - Mario
KKBOX WWDC17 UIKit Drag and Drop - Mario
 
OAuth 2 Presentation
OAuth 2 PresentationOAuth 2 Presentation
OAuth 2 Presentation
 
A simple PHP LinkedIn OAuth 2.0 example
A simple PHP LinkedIn OAuth 2.0 exampleA simple PHP LinkedIn OAuth 2.0 example
A simple PHP LinkedIn OAuth 2.0 example
 

Ähnlich wie TechCrunch Hackathon Douban API

Ähnlich wie TechCrunch Hackathon Douban API (20)

Linkedin & OAuth
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuth
 
OAuth 2.0
OAuth 2.0OAuth 2.0
OAuth 2.0
 
Secure your app with keycloak
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloak
 
Api security
Api security Api security
Api security
 
OAuth
OAuthOAuth
OAuth
 
Some OAuth love
Some OAuth loveSome OAuth love
Some OAuth love
 
Social Login
Social LoginSocial Login
Social Login
 
Oauth2.0
Oauth2.0Oauth2.0
Oauth2.0
 
Securing APIs with OAuth 2.0
Securing APIs with OAuth 2.0Securing APIs with OAuth 2.0
Securing APIs with OAuth 2.0
 
Создание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружениеСоздание API, которое полюбят разработчики. Глубокое погружение
Создание API, которое полюбят разработчики. Глубокое погружение
 
Keycloak for Science Gateways - SGCI Technology Sampler Webinar
Keycloak for Science Gateways - SGCI Technology Sampler WebinarKeycloak for Science Gateways - SGCI Technology Sampler Webinar
Keycloak for Science Gateways - SGCI Technology Sampler Webinar
 
Mobile Authentication - Onboarding, best practices & anti-patterns
Mobile Authentication - Onboarding, best practices & anti-patternsMobile Authentication - Onboarding, best practices & anti-patterns
Mobile Authentication - Onboarding, best practices & anti-patterns
 
Spring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing PeopleSpring Social - Messaging Friends & Influencing People
Spring Social - Messaging Friends & Influencing People
 
OAuth 1.0
OAuth 1.0OAuth 1.0
OAuth 1.0
 
APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可APIエコノミー時代の認証・認可
APIエコノミー時代の認証・認可
 
Data Synchronization Patterns in Mobile Application Design
Data Synchronization Patterns in Mobile Application DesignData Synchronization Patterns in Mobile Application Design
Data Synchronization Patterns in Mobile Application Design
 
Web API 2 Token Based Authentication
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
 
Kt 15 07-2013
Kt 15 07-2013Kt 15 07-2013
Kt 15 07-2013
 
Adding Identity Management and Access Control to your App
Adding Identity Management and Access Control to your AppAdding Identity Management and Access Control to your App
Adding Identity Management and Access Control to your App
 
Adding identity management and access control to your app
Adding identity management and access control to your appAdding identity management and access control to your app
Adding identity management and access control to your app
 

Kürzlich hochgeladen

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Kürzlich hochgeladen (20)

GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
Deploy with confidence: VMware Cloud Foundation 5.1 on next gen Dell PowerEdg...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 

TechCrunch Hackathon Douban API

  • 1. Douban API laiwei@douban.com http://douban.com/people/laiwei 2011-10-29
  • 2. What is Douban • Community • Book • Movie • Music • FM • AlphaTown Explore Life, Express Youself, Share Life via http://douban.com/about
  • 3. Why Douban • 50M+ Registered Users • 600+ Cities • 250,000+ Groups • 30000+ Sites • 1000+ Cinemas
  • 4. Douban APIs • Miniblog/Shuo • OpenID • Books/Movies/Music • Photos • Reviews • Collections • Notes • Events • Recommendations • Tags • Dou-mail via http://www.douban.com/service/apidoc/reference
  • 5. Powered by Douban API • DoubanShuo via http://shuo.douban.com
  • 6. Powered by Douban API • Douban FM • Douban Movie • Douban Bookcart • AlphaTown
  • 7. Powered by Douban API • Third-party Apps via http://douban.com/service/gallery
  • 8. Douban Open Platform • OpenID • API
  • 9. Douban OpenID • 3rd-party sites and applications can let visitors sign in using their douban id
  • 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 user's data and a long-lived refresh token.
  • 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. Apply Douban Apikey go to https://www.douban.com/service/auth2/apikey/apply then douban will return a apikey and secret: • apikey="047e255f2309478c0d7a701d691bd6a4" • secret="0253348fa4d10541
  • 13. Modify Apikey Properties go to https://www.douban.com/service/auth2/apikey/
  • 14. Client Side Flow 1. 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_w 2. use access_token access api curl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764"
  • 15. Server Side Flow 2 steps to obtain access_token
  • 16. Server Side Flow 1.get authorization code GET 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. Server Side Flow 2. get access_token using the code that first step returned curl "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. Server Side Flow 3. use access_token access APIs curl "https://api.douban.com/people/@me" -H "Authorization: Bearer ee905e14b2e427cccbb11a3e18ac7764
  • 19. Native-application Flow The same as server side flow