npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

google-oauth-quick-token

v1.0.0

Published

Simple cli tool to quickly approve and retrieve Google OAuth2 tokens for making request to Google APIs.

Downloads

1

Readme

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