Sha256: 6e095f42e8833020cc49b7cb51332fb5b72216ce6121a9c1e3079d71e2667ee8

Contents?: true

Size: 1.01 KB

Versions: 1

Compression:

Stored size: 1.01 KB

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class Withings < OmniAuth::Strategies::OAuth2
      option :name, 'withings'

      option :client_options, {
        :site => 'https://account.withings.com',
        :authorize_url => 'https://account.withings.com/oauth2_user/authorize2',
        :token_url => 'https://account.withings.com/oauth2/token'
      }

      option :scope, 'user.info'

      uid do
        raw_info['userid']
      end

      info do
        {
          'auth' => raw_info
        }
      end

      def callback_url
        full_host + script_name + callback_path
      end

      alias :oauth2_access_token :access_token

      def access_token
        ::OAuth2::AccessToken.new(client, oauth2_access_token.token, {
          :expires_in => oauth2_access_token.expires_in,
          :expires_at => oauth2_access_token.expires_at
        })
      end

      def raw_info
        oauth2_access_token
      end
    end
  end
end

OmniAuth.config.add_camelization 'withings', 'Withings'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-withings-oauth2-1.0.0 lib/omniauth/strategies/withings.rb