Skip to content

Commit 2ebcd4b

Browse files
committed
Update to v2.0 URIs and remove unknown resource params
1 parent 6e9f785 commit 2ebcd4b

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lib/omniauth/strategies/microsoft_graph.rb

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,22 @@ class MicrosoftGraph < OmniAuth::Strategies::OAuth2
66
option :name, :microsoft_graph
77

88
option :client_options, {
9-
site: 'https://login.microsoftonline.com/common/oauth2/authorize',
10-
token_url: 'https://login.microsoftonline.com/common/oauth2/token',
11-
authorize_url: 'https://login.microsoftonline.com/common/oauth2/authorize'
9+
site: 'https://login.microsoftonline.com',
10+
token_url: '/common/oauth2/v2.0/token',
11+
authorize_url: '/common/oauth2/v2.0/authorize'
1212
}
1313

14-
option :authorize_params, {
15-
resource: 'https://graph.microsoft.com/'
16-
}
17-
18-
option :token_params, {
19-
resource: 'https://graph.microsoft.com/'
20-
}
14+
option :authorize_options, [:scope]
2115

2216
uid { raw_info["id"] }
2317

2418
info do
2519
{
26-
'email' => raw_info["mail"],
27-
'first_name' => raw_info["givenName"],
28-
'last_name' => raw_info["surname"],
29-
'name' => [raw_info["givenName"], raw_info["surname"]].join(' '),
30-
'nickname' => raw_info["displayName"],
20+
email: raw_info["mail"],
21+
first_name: raw_info["givenName"],
22+
last_name: raw_info["surname"],
23+
name: full_name,
24+
nickname: raw_info["displayName"],
3125
}
3226
end
3327

@@ -39,7 +33,11 @@ class MicrosoftGraph < OmniAuth::Strategies::OAuth2
3933
end
4034

4135
def raw_info
42-
@raw_info ||= access_token.get(authorize_params.resource + 'v1.0/me').parsed
36+
@raw_info ||= access_token.get('/v2.0/me').parsed
37+
end
38+
39+
def full_name
40+
[raw_info["givenName"], raw_info["surname"]].compact.join(' ')
4341
end
4442
end
4543
end

0 commit comments

Comments
 (0)