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

koshilife/omniauth-tanita

Repository files navigation

OmniAuth::Tanita

Test codecov Gem Version license

This gem contains the Tanita Health Planet 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 Health Planet API Settings page and create an application. Take note of your API keys.

Using This Strategy

First start by adding this gem to your Gemfile:

gem 'omniauth-tanita'

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

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

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
  provider :tanita, "API_KEY", "API_SECRET"
end

Replace "API_KEY" and "API_SECRET" with the appropriate values you obtained earlier.

Scopes

The default scope is "innerscan". If you use other scope, you can specify like so:

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

  # Sphygmomanometer
  provider :tanita, "API_KEY", "API_SECRET", :scope => 'sphygmomanometer'

  # Pedometer and Smug
  provider :tanita, "API_KEY", "API_SECRET", :scope => ['pedometer', 'smug'].join(',')

end

Auth Hash Example

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

{
    "provider": "tanita",
    "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-tanita project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.