lib/omniauth/strategies/nexaas_id.rb in omniauth-nexaas_id-0.1.1 vs lib/omniauth/strategies/nexaas_id.rb in omniauth-nexaas_id-0.1.2
- old
+ new
@@ -3,14 +3,19 @@
OmniAuth.config.add_camelization('nexaas_id', 'NexaasID')
module OmniAuth
module Strategies
class NexaasID < OmniAuth::Strategies::OAuth2
- DEFAULT_SCOPE = 'profile invite'
+ DEFAULT_SCOPE = 'profile invite'.freeze
+ def initialize(*args)
+ @api_token = nil
+ super
+ end
+
option :name, :nexaas_id
- option :client_options, { site: 'https://id.nexaas.com' }
+ option :client_options, site: 'https://id.nexaas.com'
uid do
raw_info['id']
end
@@ -27,11 +32,12 @@
}
end
extra do
{
- 'raw_info' => raw_info
+ raw_info: raw_info,
+ legacy: { api_token: @api_token }
}
end
# Example:
#
@@ -53,9 +59,18 @@
end
def request_phase
options[:authorize_params][:scopes] = options['scope'] || DEFAULT_SCOPE
super
+ end
+
+ protected
+
+ def build_access_token
+ if (token = super) && token.params
+ @api_token = token.params['api_token']
+ end
+ token
end
end
end
end