No release in over a year
Perform Google OAuth authentication from the CLI using redirect flows. Authentication information is saved in a file and can be used for the next authentication.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 0.5.0, < 2.0.0
~> 2.5
 Project Readme

google-oauth-cli

gem version test

google-oauth-cli is a RubyGems library that allows you to perform OAuth authentication with Google from the CLI.

Features

  • Authenticate with Google using OAuth from the CLI.
  • Start a simple web server to receive authentication codes.
  • You can persist a refresh token by passing a file path as an optional argument. If a refresh token is present, the authentication flow is skipped and the access token refresh process is performed.

Motivation

Google deprecates to the OOB flow by Google in February 2022.

Usage

auth = GoogleOAuthCli.new(
  client_id: ENV["client_id"],
  client_secret: ENV["client_secret"],
  scope: ["https://www.googleapis.com/auth/drive", "https://spreadsheets.google.com/feeds"],
  credentials_file: "~/.config/google-test.json"
)

# Starts authentication flow and returns Google::Auth::UserRefreshCredentials
credentials = auth.login

drive = Google::Apis::DriveV3::DriveService.new
drive.authorization = credentials

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and the created tag, and push the .gem file to rubygems.org.

License

MIT