Class: OmniAuth::Strategies::MicrosoftGraph

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

Instance Method Summary collapse

Instance Method Details

#authorize_params ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/omniauth/strategies/microsoft_graph.rb', line 43

def authorize_params
  super.tap do |params|
    %w[display score auth_type].each do |v|
      if request.params[v]
        params[v.to_sym] = request.params[v]
      end
    end
  end
end

#build_access_token ⇒ Object



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

def build_access_token
  if request.params['access_token']
    ::OAuth2::AccessToken.from_hash(client, request.params.dup)
  else
    super
  end
end

#callback_url ⇒ Object



35
36
37
# File 'lib/omniauth/strategies/microsoft_graph.rb', line 35

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

#full_name ⇒ Object



53
54
55
# File 'lib/omniauth/strategies/microsoft_graph.rb', line 53

def full_name
  raw_info["displayName"].presence || raw_info.values_at("givenName", "surname").compact.join(' ')
end

#raw_info ⇒ Object



39
40
41
# File 'lib/omniauth/strategies/microsoft_graph.rb', line 39

def raw_info
  @raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me').parsed
end