google-auth
Google OAuth2 library for crystal
Installation
-
Add the dependency to your
shard.yml
:dependencies: google-auth: github: cyangle/google-auth version: ~> 0.1.1
-
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
- Fork it (https://github.com/cyangle/google-auth/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- Chao Yang - creator and maintainer