Class: OmniAuth::Strategies::FortnoxOauth2

Inherits:
OAuth2
  • Object
show all
Defined in:
lib/omniauth/strategies/fortnox_oauth2.rb

Overview

Fortnox

Constant Summary collapse

DEFAULT_SCOPE =
'companyinformation'

Instance Method Summary collapse

Instance Method Details

#build_access_tokenObject



70
71
72
73
74
75
76
77
78
# File 'lib/omniauth/strategies/fortnox_oauth2.rb', line 70

def build_access_token
  verifier = request.params['code']

  client.auth_code.get_token(
    verifier,
    { redirect_uri: callback_url }.merge(token_params.to_hash(symbolize_keys: true)),
    deep_symbolize(options.auth_token_params)
  )
end

#callback_urlObject



66
67
68
# File 'lib/omniauth/strategies/fortnox_oauth2.rb', line 66

def callback_url
  options[:callback_url] || (full_host + script_name + callback_path)
end

#raw_infoObject



49
50
51
52
53
54
# File 'lib/omniauth/strategies/fortnox_oauth2.rb', line 49

def raw_info
  return if access_token.blank?

  api_client = OmniAuth::FortnoxOAuth2::API.new(access_token&.token)
  @raw_info ||= api_client.get('/companyinformation')
end

#request_phaseObject



56
57
58
59
60
61
62
63
64
# File 'lib/omniauth/strategies/fortnox_oauth2.rb', line 56

def request_phase
  options[:authorize_params] = {
    client_id: options['client_id'],
    response_type: 'code',
    scope: (options['scope'] || DEFAULT_SCOPE)
  }.merge( options['account_type'] ? { account_type: options['account_type'] } : {} )

  super
end