Using OAuth with Google APIs
This is a guide to using OAuth with Google APIs. This document shows how to get a Refresh Token which you can use inside your application.
Get a Google Refresh Token
- Login to your google account
- Create project
- Create a new set of credentials. Ensure you are creating OAuth Client credentials. Set https://developers.google.com/oauthplayground as a valid redirect URI.
- Note the client ID (web app) and Client Secret
- Go to Google Oauth2 playground
- In Settings (gear icon), set
Oauth flow: Server
Access type: offline
Use your own OAuth credentials: TICK
Client Id and Client Secret: from step 5
- Click Step 1 on the left navigation window and choose Drive API https://www.googleapis.com/auth/drive (having said that, this technique also works for any of the Google APIs listed)
- Click Authorize APIs. You will be prompted to choose your Google account and confirm access
- Click Step 2 and "Exchange Authorization code for tokens"
- Copy the returned Refresh Token and paste it into your app, source code or in to some form of storage from where your app can retrieve it.