GithubHelp home page GithubHelp logo

ckimrie / google-oauth-quick-token Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 128 KB

Command line to tool to quickly retrieve an Google OAuth2 tokens for API access to Google APIs.

JavaScript 100.00%

google-oauth-quick-token's Introduction

Quick Google OAuth2 Token Retrieval

TL;DR

Command line to tool to quickly retrieve an Google OAuth2 tokens for API access to Google APIs.

Intro

Most Google APIs only allow access by using OAuth2 as the authorisation mechanism. If you're running a background process or application without a GUI it can be tricky to get started since OAuth2 requires a step where a logged in user authorises your application (typically via a browser) before you can retrieve an API access token. Once the token is retrieved, this step will not need to be repeated since most OAuth applications will refresh their tokens automatically.

This commandline script lets you very quickly retrieve an OAuth2 token you can then use in your application to make requests to Google APIs.

What you'll need:

  • This script installed globally by using npm install google-oauth-quick-token -g
  • OAuth Client Id & Client Secret for your application (see below on where to get these)

Running the program

  • Once installed (see above), run google-oauth-quick-token from the command line
  • When prompted, enter your OAuth Client ID and Client Secret (see below)
  • Select what APIs you want to request access for. Use up/down arrows and spacebar to select.
  • Select what API scopes you want to request access for. Use up/down arrows and spacebar to select.
  • Your browser will then open at a Google OAuth permission screen. Verify you are logged into the correct account and select "Authorize"
  • Your browser will then present you with your OAuth2 tokens. Copy & paste into your application and use as needed.

Client Id & Client Secret

The way OAuth2 works is that your application has a unique identifier and a person then authorises that application identifier to be able to access the persons data via an API.

These steps are designed for an application that has no GUI and needs long life tokens. If your application has a GUI, then it is better to follow the recommended OAuth flow described by Google.

  • Go to the Google Developer Console and login using the Google ID you want to 'own' the application
  • Create a new project
  • When inside the new project, select APIs & auth then APIs from the side menu and select what APIs you want to enable for your application
  • Then select Credentials and then Add credentials (if this is the first time you may be prompted to create an OAuth consent screen).
  • Choose Other as the Application type
  • Enter a name for your API credentials
  • Your client ID and client secret will be presented to you. Copy/paste or record them somewhere since you will need them to fetch your OAuth2 tokens

google-oauth-quick-token's People

Stargazers

 avatar Jake King avatar Jordan Adams avatar Joel Noir avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.