SlideShare une entreprise Scribd logo
1  sur  16
Calling an OAuth 1.0a Service from
 an OAuth 2.0-protected Service
         By Travis Spencer
      email@travisspencer.com
Basic Rundown
• You want to call the Twitter API from your own API
• The Twitter service is an OAuth 1.0a Resource Server (RS)
• Twitter has an OAuth 1.0a Authorization Server (AS)
• The Twitter service naturally only trusts it's own AS
• Your service is an OAuth 2 RS and an OAuth 1.0a Twitter client
• You have an OAuth 2 AS
• Your service naturally only trusts your AS
• The Web app that calls your service is an OAuth 2.0 client and must
  submit Access Tokens (ATs) emitted by your AS (not Twitter's) when
  calling your service
• The Resource Owner (RO) is a Twitter user and will authorize your
  service to call the Twitter API to modify their data
• The RO authenticates to your AS using Twitter's OAuth 1.0a AS
• Your AS asks the RO to authorize a third-party client of your service
User indicates that they would like to grant some Web site
access to the resources that your service provides.


                                                              Twitter’s
               Twitter User
                                                             OAuth 1.0a
                   (RO)
                                                                AS




                                                              Twitter API
                                           Your OAuth
                                                             (OAuth 1.0a
                                             2.0 AS
                                                                  RS)




                Third-party                  Your API
                 Web site                  (OAuth 2.0
                (OAuth 2.0                  RS/OAuth
                  Client)                  1.0a Client)
User is redirected to your OAuth 2.0 AS.



                                                           Twitter’s
               Twitter User
                                                          OAuth 1.0a
                   (RO)
                                                             AS




                                                           Twitter API
                                           Your OAuth
                                                          (OAuth 1.0a
                                             2.0 AS
                                                               RS)




                Third-party                  Your API
                 Web site                  (OAuth 2.0
                (OAuth 2.0                  RS/OAuth
                  Client)                  1.0a Client)
Your AS gets a Request Token (RT) from Twitter’s AS by
making an authenticated call using your Twitter client key.


                                                               Twitter’s
                Twitter User
                                                              OAuth 1.0a
                    (RO)
                                                                 AS




                                                               Twitter API
                                            Your OAuth
                                                              (OAuth 1.0a
                                              2.0 AS
                                                                   RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
Your AS redirects the user to Twitter w/ the RT and a digital
signature.


                                                                 Twitter’s
                Twitter User
                                                                OAuth 1.0a
                    (RO)
                                                                   AS




                                                                 Twitter API
                                            Your OAuth
                                                                (OAuth 1.0a
                                              2.0 AS
                                                                     RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
The user authenticates to Twitter if they don’t have a
session already.


                                                            Twitter’s
                Twitter User
                                                           OAuth 1.0a
                    (RO)
                                                              AS




                                                            Twitter API
                                            Your OAuth
                                                           (OAuth 1.0a
                                              2.0 AS
                                                                RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
The user grants your API access to Twitter’s API.



                                                            Twitter’s
                Twitter User
                                                           OAuth 1.0a
                    (RO)
                                                              AS




                                                            Twitter API
                                            Your OAuth
                                                           (OAuth 1.0a
                                              2.0 AS
                                                                RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
Twitter redirects the user to your AS’s callback URL w/ the
RT from before.


                                                               Twitter’s
                Twitter User
                                                              OAuth 1.0a
                    (RO)
                                                                 AS




                                                               Twitter API
                                            Your OAuth
                                                              (OAuth 1.0a
                                              2.0 AS
                                                                   RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
Your AS exchanges the RT for an Access Token (AT) and
stores/associates this with the user.


                                                          Twitter’s
               Twitter User
                                                         OAuth 1.0a
                   (RO)
                                                            AS




                                                          Twitter API
                                          Your OAuth
                                                         (OAuth 1.0a
                                            2.0 AS
                                                              RS)




               Third-party                  Your API
                Web site                  (OAuth 2.0
               (OAuth 2.0                  RS/OAuth
                 Client)                  1.0a Client)
Your AS redirects the user with an Access Code (AC) to the
callback URL of the third-party consumer of your API.


                                                              Twitter’s
               Twitter User
                                                             OAuth 1.0a
                   (RO)
                                                                AS




                                                              Twitter API
                                           Your OAuth
                                                             (OAuth 1.0a
                                             2.0 AS
                                                                  RS)




                Third-party                  Your API
                 Web site                  (OAuth 2.0
                (OAuth 2.0                  RS/OAuth
                  Client)                  1.0a Client)
The client exchanges the AC for a new AT specific to your
API by authenticating w/ the client key you gave them.


                                                             Twitter’s
               Twitter User
                                                            OAuth 1.0a
                   (RO)
                                                               AS




                                                             Twitter API
                                           Your OAuth
                                                            (OAuth 1.0a
                                             2.0 AS
                                                                 RS)




                Third-party                  Your API
                 Web site                  (OAuth 2.0
                (OAuth 2.0                  RS/OAuth
                  Client)                  1.0a Client)
The client calls your API with an AT from your AS.



                                                            Twitter’s
                Twitter User
                                                           OAuth 1.0a
                    (RO)
                                                              AS




                                                            Twitter API
                                            Your OAuth
                                                           (OAuth 1.0a
                                              2.0 AS
                                                                RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
Your API looks up the Twitter AT by submitting the one
presented to your API.


                                                           Twitter’s
               Twitter User
                                                          OAuth 1.0a
                   (RO)
                                                             AS




                                                           Twitter API
                                           Your OAuth
                                                          (OAuth 1.0a
                                             2.0 AS
                                                               RS)




                Third-party                  Your API
                 Web site                  (OAuth 2.0
                (OAuth 2.0                  RS/OAuth
                  Client)                  1.0a Client)
Your API calls the Twitter API using the previously granted
access.


                                                               Twitter’s
                Twitter User
                                                              OAuth 1.0a
                    (RO)
                                                                 AS




                                                               Twitter API
                                            Your OAuth
                                                              (OAuth 1.0a
                                              2.0 AS
                                                                   RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)
The Twitter data is used and your API returns the results.



                                                              Twitter’s
                Twitter User
                                                             OAuth 1.0a
                    (RO)
                                                                AS




                                                              Twitter API
                                            Your OAuth
                                                             (OAuth 1.0a
                                              2.0 AS
                                                                  RS)




                Third-party                   Your API
                 Web site                   (OAuth 2.0
                (OAuth 2.0                   RS/OAuth
                  Client)                   1.0a Client)

Contenu connexe

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 

Dernier (20)

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
 
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
 
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
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

En vedette

Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Saba Software
 

En vedette (20)

Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 

Calling an OAuth 1.0a API from an OAuth 2.0 API

  • 1. Calling an OAuth 1.0a Service from an OAuth 2.0-protected Service By Travis Spencer email@travisspencer.com
  • 2. Basic Rundown • You want to call the Twitter API from your own API • The Twitter service is an OAuth 1.0a Resource Server (RS) • Twitter has an OAuth 1.0a Authorization Server (AS) • The Twitter service naturally only trusts it's own AS • Your service is an OAuth 2 RS and an OAuth 1.0a Twitter client • You have an OAuth 2 AS • Your service naturally only trusts your AS • The Web app that calls your service is an OAuth 2.0 client and must submit Access Tokens (ATs) emitted by your AS (not Twitter's) when calling your service • The Resource Owner (RO) is a Twitter user and will authorize your service to call the Twitter API to modify their data • The RO authenticates to your AS using Twitter's OAuth 1.0a AS • Your AS asks the RO to authorize a third-party client of your service
  • 3. User indicates that they would like to grant some Web site access to the resources that your service provides. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 4. User is redirected to your OAuth 2.0 AS. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 5. Your AS gets a Request Token (RT) from Twitter’s AS by making an authenticated call using your Twitter client key. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 6. Your AS redirects the user to Twitter w/ the RT and a digital signature. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 7. The user authenticates to Twitter if they don’t have a session already. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 8. The user grants your API access to Twitter’s API. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 9. Twitter redirects the user to your AS’s callback URL w/ the RT from before. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 10. Your AS exchanges the RT for an Access Token (AT) and stores/associates this with the user. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 11. Your AS redirects the user with an Access Code (AC) to the callback URL of the third-party consumer of your API. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 12. The client exchanges the AC for a new AT specific to your API by authenticating w/ the client key you gave them. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 13. The client calls your API with an AT from your AS. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 14. Your API looks up the Twitter AT by submitting the one presented to your API. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 15. Your API calls the Twitter API using the previously granted access. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)
  • 16. The Twitter data is used and your API returns the results. Twitter’s Twitter User OAuth 1.0a (RO) AS Twitter API Your OAuth (OAuth 1.0a 2.0 AS RS) Third-party Your API Web site (OAuth 2.0 (OAuth 2.0 RS/OAuth Client) 1.0a Client)