Skip to content

Commit a454e9d

Browse files
authored
Merge pull request #11 from randomor/access_token
Accept access_token in callback phrase
2 parents 5cfc5c3 + 7cb1677 commit a454e9d

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/omniauth/strategies/microsoft_graph.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ def authorize_params
5353
def full_name
5454
raw_info["displayName"].presence || raw_info.values_at("givenName", "surname").compact.join(' ')
5555
end
56+
57+
def build_access_token
58+
if request.params['access_token']
59+
::OAuth2::AccessToken.from_hash(client, request.params.dup)
60+
else
61+
super
62+
end
63+
end
5664
end
5765
end
5866
end

test/strategy_test.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,17 @@ def test_return_id_from_raw_info
1010
assert_equal '123', strategy.uid
1111
end
1212
end
13+
14+
class AccessTokenTest < StrategyTestCase
15+
def setup
16+
super
17+
@request.stubs(:params).returns({ 'access_token' => 'valid_access_token' })
18+
strategy.stubs(:client).returns(:client)
19+
end
20+
21+
def test_build_access_token
22+
token = strategy.build_access_token
23+
assert_equal token.token, 'valid_access_token'
24+
assert_equal token.client, :client
25+
end
26+
end

test/test_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ def setup
1616

1717
@client_id = '123'
1818
@client_secret = '53cr3tz'
19+
@options = {}
1920
end
2021

2122
def strategy

0 commit comments

Comments
 (0)