Articles
google/google_api
Using OAuth with Google APIsgoogle/google_api

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

  1. Login to your google account
  2. Create project
  3. Create a new set of credentials. Ensure you are creating OAuth Client credentials. Set https://developers.google.com/oauthplayground as a valid redirect URI.
  4. Note the client ID (web app) and Client Secret
  5. Go to Google Oauth2 playground
  6. 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

  1. 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)
  2. Click Authorize APIs. You will be prompted to choose your Google account and confirm access
  3. Click Step 2 and "Exchange Authorization code for tokens"
  4. 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.