Code Monkey home page Code Monkey logo

omniauth-tanita's Introduction

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.

omniauth-tanita's People

Contributors

koshilife avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

omniauth-tanita's Issues

fail test when using omniauth-oauth2 v1.7

fail test when using omniauth-oauth2 v1.7

$ bundle exec rspec

OmniAuth::Strategies::Tanita
  client options
    has correct site
    has correct authorize_url
    has correct token_url
    has default skip_info
    has default provider_ignores_state
    has default scope
  #callback_url
    returns callback url (FAILED - 1)

Failures:

  1) OmniAuth::Strategies::Tanita#callback_url returns callback url
     Failure/Error: expect(subject.send(:callback_url)).to eq 'http://localhost/v1/auth/tanita/callback'
     
       expected: "http://localhost/v1/auth/tanita/callback"
            got: "http://localhost/v1/v1/auth/tanita/callback"
     
       (compared using ==)
     # ./spec/omniauth/strategies/tanita_spec.rb:40:in `block (3 levels) in <top (required)>'

Finished in 0.02479 seconds (files took 0.34937 seconds to load)
7 examples, 1 failure

Failed examples:

rspec ./spec/omniauth/strategies/tanita_spec.rb:37 # OmniAuth::Strategies::Tanita#callback_url returns callback url

When test don't passed Gemfile.lock is following.

    oauth2 (1.4.4)
      faraday (>= 0.8, < 2.0)
      jwt (>= 1.0, < 3.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    omniauth (2.0.3)
      hashie (>= 3.4.6)
      rack (>= 1.6.2, < 3)
      rack-protection
    omniauth-oauth2 (1.7.1)
      oauth2 (~> 1.4)
      omniauth (>= 1.9, < 3)

When test passed Gemfile.lock is following.

    oauth2 (1.4.4)
      faraday (>= 0.8, < 2.0)
      jwt (>= 1.0, < 3.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (>= 1.2, < 3)
    omniauth (1.9.1)
      hashie (>= 3.4.6)
      rack (>= 1.6.2, < 3)
    omniauth-oauth2 (1.6.0)
      oauth2 (~> 1.1)
      omniauth (~> 1.9)

diff omniauth 1.9.1 to 2.0.3
diff omniauth-oauth2 1.6.0 to 1.7.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.