Skip to content

Commit

Permalink
Merge pull request #11 from randomor/access_token
Browse files Browse the repository at this point in the history
Accept access_token in callback phrase
  • Loading branch information
synth authored Oct 17, 2018
2 parents 5cfc5c3 + 7cb1677 commit a454e9d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/omniauth/strategies/microsoft_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def authorize_params
def full_name
raw_info["displayName"].presence || raw_info.values_at("givenName", "surname").compact.join(' ')
end

def build_access_token
if request.params['access_token']
::OAuth2::AccessToken.from_hash(client, request.params.dup)
else
super
end
end
end
end
end
14 changes: 14 additions & 0 deletions test/strategy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,17 @@ def test_return_id_from_raw_info
assert_equal '123', strategy.uid
end
end

class AccessTokenTest < StrategyTestCase
def setup
super
@request.stubs(:params).returns({ 'access_token' => 'valid_access_token' })
strategy.stubs(:client).returns(:client)
end

def test_build_access_token
token = strategy.build_access_token
assert_equal token.token, 'valid_access_token'
assert_equal token.client, :client
end
end
1 change: 1 addition & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def setup

@client_id = '123'
@client_secret = '53cr3tz'
@options = {}
end

def strategy
Expand Down

0 comments on commit a454e9d

Please sign in to comment.