Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Latest commit

 

History

History
81 lines (56 loc) · 3.4 KB

README.md

File metadata and controls

81 lines (56 loc) · 3.4 KB

OmniAuth::Cybozu

Test codecov Gem Version license

This gem contains Kintone and Garoon strategy for OmniAuth.

Before You Begin

You should have already installed OmniAuth into your app; if not, read the OmniAuth README to get started.

Now sign into the Kintone Developer Program or cybozu developer network and create an application. Take note of your API keys.

Using This Strategy

First start by adding this gem to your Gemfile:

gem 'omniauth-cybozu'

If you need to use the latest HEAD version, you can do so with:

gem 'omniauth-cybozu', :github => 'koshilife/omniauth-cybozu'

Next, tell OmniAuth about this provider. For a Rails app, your config/initializers/omniauth.rb file should look like this:

Rails.application.config.middleware.use OmniAuth::Builder do

  # For kintone.com user
  # Kintone records writable
  kintone_site = 'https://{subdomain}.kintone.com'
  kintone_scope = ['k:app_record:read', 'k:app_record:write'].join(' ')
  provider :cybozu, "CLIENT_ID", "CLIENT_SECRET", { scope: kintone_scope, client_options: { site: kintone_site }}

  # For cybozu.com user
  # Garoon schedules writable
  cybozu_site = 'https://{subdomain}.cybozu.com'
  cybozu_scope = ['g:schedule:read', 'g:schedule:write'].join(' ')
  provider :cybozu, "CLIENT_ID", "CLIENT_SECRET", { scope: cybozu_scope, client_options: { site: cybozu_site }}

end

Replace "CLIENT_ID" and "CLIENT_SECRET" with the appropriate values you obtained. Refer to the Kintone Scopes or All Scopes (include Garoon) for more details on the scope.

Auth Hash Example

The auth hash request.env['omniauth.auth'] would look like this:

{
    "provider": "cybozu",
    "uid": null, // uid will be empty, because there is no apis to get.
    "credentials": {
        "token": "ACCESS_TOKEN",
        "refresh_token": "REFRESH_TOKEN",
        "expires_at": 1581419031,
        "expires": true
    },
    "extra": {}
}

Contributing

Bug reports and pull requests are welcome on GitHub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the omniauth-cybozu project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.