Skip to content

cyangle/google-auth

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

google-auth

Google OAuth2 library for crystal

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      google-auth:
        github: cyangle/google-auth
        version: ~> 0.1.1
  2. Run shards install

Usage

require "google-auth"

Load credential from json file:

cred = GoogleAuth::FileCredential.new(
  file_path: "/file/path/to/credential/json/file",
  scopes: "https://www.googleapis.com/auth/cloud-platform", # String | Array(String)
  user_agent: "crystal/client",
)

Get access token:

token = cred.get_token

puts token.token_type # => Bearer
puts token.access_token

Development

Install dependencies

shards

Run the tests:

crystal spec

Run lints

./bin/ameba
crystal tool format --check

Contributing

  1. Fork it (https://github.com/cyangle/google-auth/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors