SlideShare uma empresa Scribd logo
1 de 32
Baixar para ler offline
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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais 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
 

Mais 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)
 

Último

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rick Flair
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Último (20)

Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...Rise of the Machines: Known As Drones...
Rise of the Machines: Known As Drones...
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

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