SlideShare une entreprise Scribd logo
1  sur  32
Télécharger pour lire hors ligne
AdWords API & OAuth 2.0
Life after ClientLogin




                         Google Confidential and Proprietary
Ch-Ch-Ch-Changes




     Changes are coming for
authentication of your applications.




                             Google Confidential and Proprietary
How it works today:


1. Your app talks to authentication servers (blah blah blah)
   a. Your app gets an access token (AuthToken)

2. Your app talks to the AdWords API servers
   a. Passes in Developer Key and access token
   b. Your app has to periodically re-authenticate.

Today: blah blah blah is called ClientLogin



                                               Google Confidential and Proprietary
How it will work in the new world:


1. Your app talks to authentication servers (wah wah wah)
   a. Your app gets an access token.

2. Your app talks to the AdWords API servers
   a. Passes in Developer Key and access token
   b. Your app has to periodically re-authenticate.

New: wah wah wah is done with OAuth 2.0



                                              Google Confidential and Proprietary
DON'T PANIC!




● This shouldn't be a big deal for you.

● Will improve the security of your applications and data.




                                                       Google Confidential and Proprietary
What's wrong with ClientLogin?




● Exposes username/passwords for MCC and client
  accounts.

● AuthTokens duration 2 weeks
  ○ No way to revoke issued tokens

● Sunset by 2015
  ○ Might be sooner
  ○ Deprecated since last year



                                           Google Confidential and Proprietary
Why OAuth 2.0?

● OAuth 2.0 More secure
   ○ Does not expose password/username
   ○ Only exchange OAuth tokens
● More specific access control
   ○ Tokens can have restricted scope on data
   ○ Can easily revoke a token
   ○ Reduced impact if token compromised
● No CAPTCHA challenges.
● Have learned a lot from the mess of OAuth 1.0


                                                Google Confidential and Proprietary
Using OAuth 2.0

Your Key Steps


1. Registering the OAuth application

2. Authenticating to get access token (AuthToken) and refresh token.

3. Call the AdWords API with the access token.

4. Handle token expiration.




                                                      Google Confidential and Proprietary
Using OAuth 2.0

Step 1: Registering




                Go to:
 https://code.google.com/apis/console
             and create a new project




                                        Google Confidential and Proprietary
Google APIs Console




    Google Confidential and Proprietary
Google APIs Console




    Google Confidential and Proprietary
Google APIs Console




    Google Confidential and Proprietary
Google APIs Console




    Google Confidential and Proprietary
Google APIs Console




    Google Confidential and Proprietary
Using OAuth 2.0




Google Confidential and Proprietary
Using OAuth 2.0

Step 2: Coding for OAuth 2.0


● Are you using the client libraries?
   ● Most are already up to date
      ○ Ruby
      ○ Java (new)
      ○ .NET
      ○ Python
      ○ Perl
   ● Rest will be coming soon

                                        Google Confidential and Proprietary
Using OAuth 2.0

Step 2: Coding by Hand


1. Send a request to the Google Authorization Server, with:
    a.   what you want access to - https://adwords.google.
         com/api/adwords
    b.   and the client_id and the client_secret

2. Next step requires actual user interact with a Google webpage, that
   allows you to:
    a.   login with your MCC or client account credentials
    b.   authorize access to the given scope

3. This returns the accessToken and refreshToken to your app




                                                             Google Confidential and Proprietary
Step 2: How to use the tokens returned


       accessToken

● Access for ~ 1 hour

● Then expires




                                         Google Confidential and Proprietary
Step 2: How to use the tokens returned


       accessToken                 refreshToken

● Access for ~ 1 hour       ● Regenerates accessTokens
                            ● No user interaction required
● Then expires




                                            Google Confidential and Proprietary
Step 2: How to use the tokens returned


       accessToken                  refreshToken

● Access for ~ 1 hour       ● Regenerates accessTokens
                            ● No user interaction required
● Then expires
                            ● Be sure to store it




                                              Google Confidential and Proprietary
Step 2 (by hand): Let's look at some code




  (This code is available on the web, so don't worry if you
                   can't follow it all now.)
                     http://goo.gl/s6nmR




                                                Google Confidential and Proprietary
Sample code - authorize()
public Credential authorize() throws Exception {
  // set up file credential store to save/load tokens
  FileCredentialStore credentialStore =
      new FileCredentialStore(
         new File("~/Desktop/oauth.json"),JSON_FACTORY);
  // set up authorization code flow
  ...

    // actually authorize
    ...
}




                                          Google Confidential and Proprietary
Sample code - authorize()
public Credential authorize() throws Exception {
  // set up file credential store to save/load tokens
  FileCredentialStore credentialStore =
      new FileCredentialStore(
         new File("~/Desktop/oauth.json"),JSON_FACTORY);

    // set up authorization code flow
    GoogleAuthorizationCodeFlow flow = new
      GoogleAuthorizationCodeFlow
        .Builder(HTTP_TRANSPORT, JSON_FACTORY,
                  CLIENT_ID, CLIENT_SECRET, AWAPI_SCOPE)
        .setCredentialStore(credentialStore)
        .build();

    // actually authorize
    ...
}
                                             Google Confidential and Proprietary
Sample code - authorize()
public Credential authorize() throws Exception {
  // set up file credential store to save/load tokens
  ...

    // set up authorization code flow
    GoogleAuthorizationCodeFlow flow = new
      GoogleAuthorizationCodeFlow
        .Builder(HTTP_TRANSPORT, JSON_FACTORY,
                  CLIENT_ID, CLIENT_SECRET, AWAPI_SCOPE)
        .setCredentialStore(credentialStore)
        .build();

    // actually authorize
    return new AuthorizationCodeInstalledApp(
        flow, new LocalServerReceiver())
        .authorize("user");
}
                                             Google Confidential and Proprietary
Sample code - connect()
// Construct AdWordsSession object
AdWordsSession session =
  new AdWordsSession
   .Builder()
   .fromFile()
   .withOAuth2Credential(credential)
   .build();

// Construct AdWordsServices object
AdWordsServices adWordsServices = new AdWordsServices();




                                          Google Confidential and Proprietary
Futher Info

Authentication Flows: You've got choices


● Web Server Flow
   ○   Consent: Browser for consent
   ○   Response: Redirects user to callback endpoint



● Installed App Flow
   ○   Consent: URL provided - user pastes into browser
   ○   Response: Display code - user paste into app
                                  OR
   ○   Consent: URL Provided - in app browser
   ○   Response: Captures code - app returns to auth server

                                                 User Interaction | Programmatic

                                                           Google Confidential and Proprietary
Further Info

OAuth 2.0 Best Practices



● Use the refreshToken only on accessToken expiry

● Store the refreshToken for re-use
  ○ To reduce user interaction

● Officially clientCustomerId needed only for reports
   ○ Recommended for all



                                         Google Confidential and Proprietary
Coding by Hand: Handling Expired Tokens




● What? I need to handle token expirations?

● Theoretically, you should be able to restart requests
  today!
   ○ ClientLogin auth tokens can time out.
   ○ Server calls can fail in a way that suggest you should
      retry.




                                                 Google Confidential and Proprietary
Further Info

Coding by Hand: Error Handling


● Error: AuthenticationError.OAUTH_TOKEN_INVALID
   ○   On: accessToken expired
   ○   Resolution: use refreshToken



● Error: AuthenticationError.INVALID_GRANT_ERROR
   ○   On: accessToken revoked
   ○   Resolution: re-auth app with user consent




                                                   Google Confidential and Proprietary
Summary




● Change is coming

● Shouldn't be a big deal

   ○ Will actually improve your app security

● Client library users should be ready to go now or soon.




                                               Google Confidential and Proprietary
Q&A
Resources


Docs Links:

https://developers.google.com/accounts/docs/OAuth2

Register app, get client_id & client_secret:

https://code.google.com/apis/console

Java Sample Code:

http://goo.gl/s6nmR




                                                 Google Confidential and Proprietary

Contenu connexe

Similaire à AdWords API and OAuth 2.0

The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2Khor SoonHin
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...wesley chun
 
OAuth 2.0 refresher Talk
OAuth 2.0 refresher TalkOAuth 2.0 refresher Talk
OAuth 2.0 refresher Talkmarcwan
 
INTERFACE, by apidays - The Evolution of API Security by Johann Dilantha Nal...
INTERFACE, by apidays  - The Evolution of API Security by Johann Dilantha Nal...INTERFACE, by apidays  - The Evolution of API Security by Johann Dilantha Nal...
INTERFACE, by apidays - The Evolution of API Security by Johann Dilantha Nal...apidays
 
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...WSO2
 
Accessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) webAccessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) webFelix Arntz
 
Securing a Web App with Passwordless Web Authentication
Securing a Web App with Passwordless Web AuthenticationSecuring a Web App with Passwordless Web Authentication
Securing a Web App with Passwordless Web AuthenticationFIDO Alliance
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxChanna Ly
 
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...CloudIDSummit
 
Introduction to the Globus Platform for Developers
Introduction to the Globus Platform for DevelopersIntroduction to the Globus Platform for Developers
Introduction to the Globus Platform for DevelopersGlobus
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIGun Lee
 
Google+ Login - A Primer
Google+ Login - A PrimerGoogle+ Login - A Primer
Google+ Login - A PrimerTom Opgenorth
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTGaurav Roy
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdffindandsolve .com
 
Google auth - dispelling the magic
Google auth - dispelling the magicGoogle auth - dispelling the magic
Google auth - dispelling the magicZaar Hai
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesIntuit Developer
 
Getting started using Google APIs (2019)
Getting started using Google APIs (2019)Getting started using Google APIs (2019)
Getting started using Google APIs (2019)wesley chun
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0Yury Roa
 

Similaire à AdWords API and OAuth 2.0 (20)

The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2The Many Flavors of OAuth - Understand Everything About OAuth2
The Many Flavors of OAuth - Understand Everything About OAuth2
 
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...Build an AI/ML-driven image archive processing workflow: Image archive, analy...
Build an AI/ML-driven image archive processing workflow: Image archive, analy...
 
Securing api with_o_auth2
Securing api with_o_auth2Securing api with_o_auth2
Securing api with_o_auth2
 
OAuth 2.0 refresher Talk
OAuth 2.0 refresher TalkOAuth 2.0 refresher Talk
OAuth 2.0 refresher Talk
 
INTERFACE, by apidays - The Evolution of API Security by Johann Dilantha Nal...
INTERFACE, by apidays  - The Evolution of API Security by Johann Dilantha Nal...INTERFACE, by apidays  - The Evolution of API Security by Johann Dilantha Nal...
INTERFACE, by apidays - The Evolution of API Security by Johann Dilantha Nal...
 
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
[APIdays INTERFACE 2021] The Evolution of API Security for Client-side Applic...
 
Accessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) webAccessing APIs using OAuth on the federated (WordPress) web
Accessing APIs using OAuth on the federated (WordPress) web
 
Securing a Web App with Passwordless Web Authentication
Securing a Web App with Passwordless Web AuthenticationSecuring a Web App with Passwordless Web Authentication
Securing a Web App with Passwordless Web Authentication
 
How to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptxHow to build Simple yet powerful API.pptx
How to build Simple yet powerful API.pptx
 
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...
CIS13: So, You Want to Be a Relying Party: Federated Login with Google Identi...
 
Introduction to the Globus Platform for Developers
Introduction to the Globus Platform for DevelopersIntroduction to the Globus Platform for Developers
Introduction to the Globus Platform for Developers
 
The Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror APIThe Glass Class - Tutorial 2 - Mirror API
The Glass Class - Tutorial 2 - Mirror API
 
Google+ Login - A Primer
Google+ Login - A PrimerGoogle+ Login - A Primer
Google+ Login - A Primer
 
Stateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWT
 
Google external login setup in ASP (1).pdf
Google external login setup in ASP  (1).pdfGoogle external login setup in ASP  (1).pdf
Google external login setup in ASP (1).pdf
 
Google auth - dispelling the magic
Google auth - dispelling the magicGoogle auth - dispelling the magic
Google auth - dispelling the magic
 
OAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST ServicesOAuth for QuickBooks Online REST Services
OAuth for QuickBooks Online REST Services
 
Introduction to Google App Engine
Introduction to Google App EngineIntroduction to Google App Engine
Introduction to Google App Engine
 
Getting started using Google APIs (2019)
Getting started using Google APIs (2019)Getting started using Google APIs (2019)
Getting started using Google APIs (2019)
 
Demystifying OAuth 2.0
Demystifying OAuth 2.0Demystifying OAuth 2.0
Demystifying OAuth 2.0
 

Plus de marcwan

Mcc scripts deck (日本語)
Mcc scripts deck (日本語)Mcc scripts deck (日本語)
Mcc scripts deck (日本語)marcwan
 
Getting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords APIGetting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords APImarcwan
 
Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)marcwan
 
Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)marcwan
 
Opportunity Analysis with Kratu
Opportunity Analysis with KratuOpportunity Analysis with Kratu
Opportunity Analysis with Kratumarcwan
 
07. feeds update
07. feeds update07. feeds update
07. feeds updatemarcwan
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scriptingmarcwan
 
AwReporting Update
AwReporting UpdateAwReporting Update
AwReporting Updatemarcwan
 
Getting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google AnalyticsGetting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google Analyticsmarcwan
 
Shopping Campaigns and AdWords API
Shopping Campaigns and AdWords APIShopping Campaigns and AdWords API
Shopping Campaigns and AdWords APImarcwan
 
API Updates for v201402
API Updates for v201402API Updates for v201402
API Updates for v201402marcwan
 
AdWords API Targeting Options
AdWords API Targeting OptionsAdWords API Targeting Options
AdWords API Targeting Optionsmarcwan
 
Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)marcwan
 
Rate limits and performance (Spanish)
Rate limits and performance (Spanish)Rate limits and performance (Spanish)
Rate limits and performance (Spanish)marcwan
 
OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)marcwan
 
End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)marcwan
 
AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)marcwan
 
Api update rundown (Spanish)
Api update rundown (Spanish)Api update rundown (Spanish)
Api update rundown (Spanish)marcwan
 
AdWords Scripts (Spanish)
AdWords Scripts (Spanish)AdWords Scripts (Spanish)
AdWords Scripts (Spanish)marcwan
 
Mobile landing pages (Spanish)
Mobile landing pages (Spanish)Mobile landing pages (Spanish)
Mobile landing pages (Spanish)marcwan
 

Plus de marcwan (20)

Mcc scripts deck (日本語)
Mcc scripts deck (日本語)Mcc scripts deck (日本語)
Mcc scripts deck (日本語)
 
Getting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords APIGetting started with Google Analytics and the AdWords API
Getting started with Google Analytics and the AdWords API
 
Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)Bid Estimation with the AdWords API (v2)
Bid Estimation with the AdWords API (v2)
 
Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)Opportunity Analysis with Kratu (v2)
Opportunity Analysis with Kratu (v2)
 
Opportunity Analysis with Kratu
Opportunity Analysis with KratuOpportunity Analysis with Kratu
Opportunity Analysis with Kratu
 
07. feeds update
07. feeds update07. feeds update
07. feeds update
 
AdWords Scripts and MCC Scripting
AdWords Scripts and MCC ScriptingAdWords Scripts and MCC Scripting
AdWords Scripts and MCC Scripting
 
AwReporting Update
AwReporting UpdateAwReporting Update
AwReporting Update
 
Getting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google AnalyticsGetting Started with AdWords API and Google Analytics
Getting Started with AdWords API and Google Analytics
 
Shopping Campaigns and AdWords API
Shopping Campaigns and AdWords APIShopping Campaigns and AdWords API
Shopping Campaigns and AdWords API
 
API Updates for v201402
API Updates for v201402API Updates for v201402
API Updates for v201402
 
AdWords API Targeting Options
AdWords API Targeting OptionsAdWords API Targeting Options
AdWords API Targeting Options
 
Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)Reporting Tips and Tricks (Spanish)
Reporting Tips and Tricks (Spanish)
 
Rate limits and performance (Spanish)
Rate limits and performance (Spanish)Rate limits and performance (Spanish)
Rate limits and performance (Spanish)
 
OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)OAuth 2.0 (Spanish)
OAuth 2.0 (Spanish)
 
End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)End to-end how to build a platform (Spanish)
End to-end how to build a platform (Spanish)
 
AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)AwReporting tool introduction (Spanish)
AwReporting tool introduction (Spanish)
 
Api update rundown (Spanish)
Api update rundown (Spanish)Api update rundown (Spanish)
Api update rundown (Spanish)
 
AdWords Scripts (Spanish)
AdWords Scripts (Spanish)AdWords Scripts (Spanish)
AdWords Scripts (Spanish)
 
Mobile landing pages (Spanish)
Mobile landing pages (Spanish)Mobile landing pages (Spanish)
Mobile landing pages (Spanish)
 

Dernier

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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...Miguel Araújo
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
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 SolutionsEnterprise Knowledge
 
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 Processorsdebabhi2
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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 Scriptwesley chun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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...Drew Madelung
 

Dernier (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 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)
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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...
 

AdWords API and OAuth 2.0

  • 1. AdWords API & OAuth 2.0 Life after ClientLogin Google Confidential and Proprietary
  • 2. Ch-Ch-Ch-Changes Changes are coming for authentication of your applications. Google Confidential and Proprietary
  • 3. How it works today: 1. Your app talks to authentication servers (blah blah blah) a. Your app gets an access token (AuthToken) 2. Your app talks to the AdWords API servers a. Passes in Developer Key and access token b. Your app has to periodically re-authenticate. Today: blah blah blah is called ClientLogin Google Confidential and Proprietary
  • 4. How it will work in the new world: 1. Your app talks to authentication servers (wah wah wah) a. Your app gets an access token. 2. Your app talks to the AdWords API servers a. Passes in Developer Key and access token b. Your app has to periodically re-authenticate. New: wah wah wah is done with OAuth 2.0 Google Confidential and Proprietary
  • 5. DON'T PANIC! ● This shouldn't be a big deal for you. ● Will improve the security of your applications and data. Google Confidential and Proprietary
  • 6. What's wrong with ClientLogin? ● Exposes username/passwords for MCC and client accounts. ● AuthTokens duration 2 weeks ○ No way to revoke issued tokens ● Sunset by 2015 ○ Might be sooner ○ Deprecated since last year Google Confidential and Proprietary
  • 7. Why OAuth 2.0? ● OAuth 2.0 More secure ○ Does not expose password/username ○ Only exchange OAuth tokens ● More specific access control ○ Tokens can have restricted scope on data ○ Can easily revoke a token ○ Reduced impact if token compromised ● No CAPTCHA challenges. ● Have learned a lot from the mess of OAuth 1.0 Google Confidential and Proprietary
  • 8. Using OAuth 2.0 Your Key Steps 1. Registering the OAuth application 2. Authenticating to get access token (AuthToken) and refresh token. 3. Call the AdWords API with the access token. 4. Handle token expiration. Google Confidential and Proprietary
  • 9. Using OAuth 2.0 Step 1: Registering Go to: https://code.google.com/apis/console and create a new project Google Confidential and Proprietary
  • 10. Google APIs Console Google Confidential and Proprietary
  • 11. Google APIs Console Google Confidential and Proprietary
  • 12. Google APIs Console Google Confidential and Proprietary
  • 13. Google APIs Console Google Confidential and Proprietary
  • 14. Google APIs Console Google Confidential and Proprietary
  • 15. Using OAuth 2.0 Google Confidential and Proprietary
  • 16. Using OAuth 2.0 Step 2: Coding for OAuth 2.0 ● Are you using the client libraries? ● Most are already up to date ○ Ruby ○ Java (new) ○ .NET ○ Python ○ Perl ● Rest will be coming soon Google Confidential and Proprietary
  • 17. Using OAuth 2.0 Step 2: Coding by Hand 1. Send a request to the Google Authorization Server, with: a. what you want access to - https://adwords.google. com/api/adwords b. and the client_id and the client_secret 2. Next step requires actual user interact with a Google webpage, that allows you to: a. login with your MCC or client account credentials b. authorize access to the given scope 3. This returns the accessToken and refreshToken to your app Google Confidential and Proprietary
  • 18. Step 2: How to use the tokens returned accessToken ● Access for ~ 1 hour ● Then expires Google Confidential and Proprietary
  • 19. Step 2: How to use the tokens returned accessToken refreshToken ● Access for ~ 1 hour ● Regenerates accessTokens ● No user interaction required ● Then expires Google Confidential and Proprietary
  • 20. Step 2: How to use the tokens returned accessToken refreshToken ● Access for ~ 1 hour ● Regenerates accessTokens ● No user interaction required ● Then expires ● Be sure to store it Google Confidential and Proprietary
  • 21. Step 2 (by hand): Let's look at some code (This code is available on the web, so don't worry if you can't follow it all now.) http://goo.gl/s6nmR Google Confidential and Proprietary
  • 22. Sample code - authorize() public Credential authorize() throws Exception { // set up file credential store to save/load tokens FileCredentialStore credentialStore = new FileCredentialStore( new File("~/Desktop/oauth.json"),JSON_FACTORY); // set up authorization code flow ... // actually authorize ... } Google Confidential and Proprietary
  • 23. Sample code - authorize() public Credential authorize() throws Exception { // set up file credential store to save/load tokens FileCredentialStore credentialStore = new FileCredentialStore( new File("~/Desktop/oauth.json"),JSON_FACTORY); // set up authorization code flow GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow .Builder(HTTP_TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, AWAPI_SCOPE) .setCredentialStore(credentialStore) .build(); // actually authorize ... } Google Confidential and Proprietary
  • 24. Sample code - authorize() public Credential authorize() throws Exception { // set up file credential store to save/load tokens ... // set up authorization code flow GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow .Builder(HTTP_TRANSPORT, JSON_FACTORY, CLIENT_ID, CLIENT_SECRET, AWAPI_SCOPE) .setCredentialStore(credentialStore) .build(); // actually authorize return new AuthorizationCodeInstalledApp( flow, new LocalServerReceiver()) .authorize("user"); } Google Confidential and Proprietary
  • 25. Sample code - connect() // Construct AdWordsSession object AdWordsSession session = new AdWordsSession .Builder() .fromFile() .withOAuth2Credential(credential) .build(); // Construct AdWordsServices object AdWordsServices adWordsServices = new AdWordsServices(); Google Confidential and Proprietary
  • 26. Futher Info Authentication Flows: You've got choices ● Web Server Flow ○ Consent: Browser for consent ○ Response: Redirects user to callback endpoint ● Installed App Flow ○ Consent: URL provided - user pastes into browser ○ Response: Display code - user paste into app OR ○ Consent: URL Provided - in app browser ○ Response: Captures code - app returns to auth server User Interaction | Programmatic Google Confidential and Proprietary
  • 27. Further Info OAuth 2.0 Best Practices ● Use the refreshToken only on accessToken expiry ● Store the refreshToken for re-use ○ To reduce user interaction ● Officially clientCustomerId needed only for reports ○ Recommended for all Google Confidential and Proprietary
  • 28. Coding by Hand: Handling Expired Tokens ● What? I need to handle token expirations? ● Theoretically, you should be able to restart requests today! ○ ClientLogin auth tokens can time out. ○ Server calls can fail in a way that suggest you should retry. Google Confidential and Proprietary
  • 29. Further Info Coding by Hand: Error Handling ● Error: AuthenticationError.OAUTH_TOKEN_INVALID ○ On: accessToken expired ○ Resolution: use refreshToken ● Error: AuthenticationError.INVALID_GRANT_ERROR ○ On: accessToken revoked ○ Resolution: re-auth app with user consent Google Confidential and Proprietary
  • 30. Summary ● Change is coming ● Shouldn't be a big deal ○ Will actually improve your app security ● Client library users should be ready to go now or soon. Google Confidential and Proprietary
  • 31. Q&A
  • 32. Resources Docs Links: https://developers.google.com/accounts/docs/OAuth2 Register app, get client_id & client_secret: https://code.google.com/apis/console Java Sample Code: http://goo.gl/s6nmR Google Confidential and Proprietary