You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fan Wang edited this page Mar 12, 2020
·
6 revisions
This guide will walk you through how to setup OAuth2 for API access using your
own credentials using installed application flow.
These steps only need to be done once, unless you revoke, delete, or need to
change the allowed scopes for your OAuth2 credentials.
Run this example via the command line. You can either modify the
INSERT_XXX_HERE values in the example before running or use arguments
-client_id for client ID and -client_secret for client secret.
The example will prompt you to visit a URL where you will need to allow the
OAuth2 credentials to access your Google Ads account on your behalf.
Paste this url in your browser:
https://accounts.google.com/o/oauth2/v2/auth?response_type=code&access_type=offline&client_id=...
Navigate to the URL in a private browser session or an incognito window. Log
in with the same Google account you use to access Google Ads. Click Allow
on the OAuth2 consent screen.
An authorization code will be shown to you.
Copy and paste the authorization code into the command line where you're
running the authenticate_in_standalone_application.pl example and press
enter. The example will complete and display your refresh token and some
instructions, followed by the properties you'll need to configure the client
library:
Type the authorization code you received here: ****
Replace the following keys and values in your googleads.properties configuration file:
clientId=***********************apps.googleusercontent.com
clientSecret=****
refreshToken=****
Copy the generated refresh token along with the client ID, client secret into
your googleads.properties or save it somewhere else to use it to instantiate
the library at runtime.