Google OAuth2 library for crystal
-
Add the dependency to your
shard.yml:dependencies: google-auth: github: cyangle/google-auth version: ~> 0.1.1
-
Run
shards install
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_tokenInstall dependencies
shardsRun the tests:
crystal specRun lints
./bin/ameba
crystal tool format --check- 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
- Chao Yang - creator and maintainer