Sha256: 25fdb5c4676f3646252aa8ed13305cbb672b466d4382d78db02823c7a196ff68

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

require 'omniauth-oauth2'

module OmniAuth
  module Strategies
    class FreeAgent < OmniAuth::Strategies::OAuth2
      option :name, 'freeagent'
      
      option :client_options, {
        :site => 'https://api.freeagent.com',
        :authorize_url => '/v2/approve_app',
        :token_url => '/v2/token_endpoint'
      }

      uid do
        raw_info['url'].split('/').last.to_i
      end

      info do
        {
          'email' => raw_info['email'],
          'first_name' => raw_info['first_name'],
          'last_name' => raw_info['last_name'],
          'url' => raw_info['url']
        }
      end

      extra do
        {
          "raw_info" => raw_info
        }
      end

      def raw_info
        @raw_info ||= access_token.get('/v2/users/me').parsed['user']
      end
    end
  end
end

OmniAuth.config.add_camelization 'freeagent', 'FreeAgent'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
omniauth-freeagent-0.0.1 lib/omniauth/strategies/freeagent.rb