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:
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:
Pressing the Create and OAuth 2.0 Client ID… button will bring up a wizard to guide you through the creation process:
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:
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: