Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #331 from jugyo/master

fix to refresh the expired access token properly
  • Loading branch information...
commit 07b8b45ecdb22b23dfa5fb4c8288a907319e4089 2 parents 4401851 + 43ecdfb
@sferik sferik authored
Showing with 2 additions and 14 deletions.
  1. +2 −14 oa-oauth/lib/omniauth/strategies/oauth2.rb
View
16 oa-oauth/lib/omniauth/strategies/oauth2.rb
@@ -64,16 +64,7 @@ def callback_phase
end
@access_token = build_access_token
-
- if @access_token.expires? && @access_token.expires_in <= 0
- client.request(:post, client.access_token_url, {
- 'client_id' => client_id,
- 'grant_type' => 'refresh_token',
- 'client_secret' => client_secret,
- 'refresh_token' => @access_token.refresh_token
- }.merge(options))
- @access_token = client.web_server.get_access_token(verifier, {:redirect_uri => callback_url}.merge(options))
- end
+ @access_token = client.web_server.refresh_access_token(@access_token.refresh_token) if @access_token.expired?
super
rescue ::OAuth2::HTTPError, ::OAuth2::AccessDenied, CallbackError => e
@@ -84,11 +75,8 @@ def callback_phase
fail!(:timeout, e)
end
- def verifier
- request.params['code']
- end
-
def build_access_token
+ verifier = request.params['code']
client.web_server.get_access_token(verifier, {:redirect_uri => callback_url}.merge(options))
end
Please sign in to comment.
Something went wrong with that request. Please try again.