Skip to content

Commit

Permalink
avoid changing method visibility from omniauth-oauth2
Browse files Browse the repository at this point in the history
  • Loading branch information
mkdynamic committed Dec 3, 2013
1 parent 3e8a216 commit 92d1134
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
32 changes: 17 additions & 15 deletions lib/omniauth/strategies/facebook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,6 @@ def info_options
{ :params => params }
end

def build_access_token
if signed_request_contains_access_token?
hash = signed_request.clone
::OAuth2::AccessToken.new(
client,
hash.delete('oauth_token'),
hash.merge!(access_token_options.merge(:expires_at => hash.delete('expires')))
)
else
with_authorization_code! { super }.tap do |token|
token.options.merge!(access_token_options)
end
end
end

def callback_phase
super
rescue NoAuthorizationCodeError => e
Expand Down Expand Up @@ -154,6 +139,23 @@ def signed_request
parse_signed_request(raw_signed_request)
end

protected

def build_access_token
if signed_request_contains_access_token?
hash = signed_request.clone
::OAuth2::AccessToken.new(
client,
hash.delete('oauth_token'),
hash.merge!(access_token_options.merge(:expires_at => hash.delete('expires')))
)
else
with_authorization_code! { super }.tap do |token|
token.options.merge!(access_token_options)
end
end
end

private

def raw_signed_request
Expand Down
4 changes: 2 additions & 2 deletions test/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,13 +532,13 @@ def setup
end

test 'returns a new access token from the signed request' do
result = strategy.build_access_token
result = strategy.send(:build_access_token)
assert_kind_of ::OAuth2::AccessToken, result
assert_equal @payload['oauth_token'], result.token
end

test 'returns an access token with the correct expiry time' do
result = strategy.build_access_token
result = strategy.send(:build_access_token)
assert_equal @payload['expires'], result.expires_at
end
end
Expand Down

0 comments on commit 92d1134

Please sign in to comment.