Obtaining OAuth 2.0 Access Tokens from Google

in AdWords API

To use OAuth 2.0, you need to supply a Redirect URL, and your Client Id and Client Secret tokens. These can be obtained by signing up at the Google API Console. If you've never used it before, then the first thing you need to do—after signing in with your Google Account—is create a project. You should be presented with the following screen:

Creating a Project in the API Console
Creating a Project in the API Console

Just press the Create Project button, to generate a generic project, called “API Project”, then you will be taken to the dashboard. Next, click on the API Access tab, and you should be presented with the following screen:

The API Access Tab of a New Project
The API Access Tab of a New Project

Pressing the Create and OAuth 2.0 Client ID… button will bring up a wizard to guide you through the creation process:

Branding Information for your Tool
Branding Information for your Tool

This first screen lets you enter branding information that's displayed when your users are taken to Google's OAuth console; you can display a product name, logo, and homepage URL. Clicking on the Next button takes you to the next screen where you specify the settings for your application:

OAuth Settings for your Tool
OAuth Settings for your Tool

For this tutorial I'm going to stick with the most common scenario of a web application, but if you would like to learn about the alternative scenarios then you can check out the Google OAuth Documentation.

For a web application, you need to specify a URL that you want your users to be sent to after granting your tool access to their Google account; this can be entered into the your site or hostname box on the screen, and will be transferred to the Redirect URL section once you press the tab key. So, in the above screen, I entered test.ewanheming.com/oauth_return.php into the box, pressed tab, and https://test.ewanheming.com/oauth_return.php was set as the redirect URL.

Once this is complete, you'll be shown a screen containing your Client ID and Client Secret tokens:

Your Client ID and Client Secret
Your Client ID and Client Secret

← Facebook Ads Manager Security Downloading Reports from the Bing Ads API →

To help me decide what to write about, I'd like to asses the value of my blog posts to see which ones people find most beneficial. If you found the information here useful then could you please +1 it, but if you didn't find what you were looking for then please leave a comment and I'll be happy to help where I can. Thanks!

Comments

I'm keen to get feedback on my posts, so if you have any questions or comments, then please send me a message and I'll be happy to help.