Skip to content

Commit 1d6e58e

Browse files
committed
Fix loading user data and configurable params
1 parent 2ebcd4b commit 1d6e58e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

lib/omniauth/strategies/microsoft_graph.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ class MicrosoftGraph < OmniAuth::Strategies::OAuth2
1111
authorize_url: '/common/oauth2/v2.0/authorize'
1212
}
1313

14-
option :authorize_options, [:scope]
14+
option :authorize_options, %i[display score auth_type scope prompt login_hint domain_hint response_mode state]
1515

1616
uid { raw_info["id"] }
1717

1818
info do
1919
{
20-
email: raw_info["mail"],
20+
email: raw_info["mail"] || raw_info["userPrincipalName"],
2121
first_name: raw_info["givenName"],
2222
last_name: raw_info["surname"],
2323
name: full_name,
24-
nickname: raw_info["displayName"],
24+
nickname: raw_info["userPrincipalName"],
2525
}
2626
end
2727

@@ -33,7 +33,17 @@ class MicrosoftGraph < OmniAuth::Strategies::OAuth2
3333
end
3434

3535
def raw_info
36-
@raw_info ||= access_token.get('/v2.0/me').parsed
36+
@raw_info ||= access_token.get('https://graph.microsoft.com/v1.0/me').parsed
37+
end
38+
39+
def authorize_params
40+
super.tap do |params|
41+
%w[display score auth_type].each do |v|
42+
if request.params[v]
43+
params[v.to_sym] = request.params[v]
44+
end
45+
end
46+
end
3747
end
3848

3949
def full_name

0 commit comments

Comments
 (0)