Sha256: d7075c785da7be04bca775f7de7243579a9f74c8cc12199f4cb2b0cbc3f1b42e

Contents?: true

Size: 906 Bytes

Versions: 1

Compression:

Stored size: 906 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class RDStation < OmniAuth::Strategies::OAuth2
      option :name, 'rdstation'

      args %i[client_id client_secret]

      option :client_options,
             site: 'https://api.rd.services',
             authorize_url: 'https://api.rd.services/auth/dialog',
             token_url: 'auth/token'

      def request_phase
        auth_url = { redirect_url: callback_url }.merge(authorize_params)
        redirect client.auth_code.authorize_url(auth_url)
      end

      info do
        { 'account_name' => raw_info['name'] }
      end

      extra do
        { 'raw_info' => raw_info }
      end

      def raw_info
        @raw_info ||= MultiJson.decode(
          access_token.get('https://api.rd.services/marketing/account_info').body
        )
      end
    end
  end
end

OmniAuth.config.add_camelization 'rdstation', 'RDStation'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-rdstation-0.2.0 lib/omniauth/strategies/rdstation.rb