Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #506 from altuure/0-3-stable

0 3 stable
  • Loading branch information...
commit 2447925e1107e7c3b4a39714e168aad6c7a5d556 2 parents ccad9fa + 7ea4a47
Erik Michaels-Ober sferik authored
Showing with 31 additions and 2 deletions.
  1. +31 −2 oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb
33 oa-oauth/lib/omniauth/strategies/oauth2/gowalla.rb
View
@@ -26,6 +26,7 @@ def auth_hash
super, {
'uid' => user_data['url'].split('/').last,
'user_info' => user_info,
+ 'credentials' => {'refresh_token' => @access_token.refresh_token},
'extra' => {
'user_hash' => user_data,
'refresh_token' => refresh_token,
@@ -34,10 +35,22 @@ def auth_hash
}
)
end
-
def user_data
- @data ||= MultiJson.decode(@access_token.get('/users/me.json'))
+ puts "user_data"
+ if(@data.nil?)
+ opts={
+ :raise_errors=>false,
+ :headers =>{:Accept => 'application/json','X-Gowalla-API-Key'=> self.client_id},
+ :params=>{:oauth_token=>@access_token.token}
+ }
+ response=@access_token.get('http://api.gowalla.com/users/me',opts)
+
+ @data = MultiJson.decode(response.body)
+ end
+
+ @data
end
+
def refresh_token
@refresh_token ||= @access_token.refresh_token
@@ -53,6 +66,7 @@ def request_phase
end
def user_info
+
{
'name' => "#{user_data['first_name']} #{user_data['last_name']}",
'nickname' => user_data['username'],
@@ -67,6 +81,21 @@ def user_info
},
}
end
+ def build_access_token
+ token=super
+ ##remove expires_at from token, invalid format
+ token=::OAuth2::AccessToken.new(token.client,token.token,{:expires_in=>token.expires_in,:refresh_token=>token.refresh_token}.merge(token.params))
+ ## if token is expired refresh and again remove expires_at
+ if token.expired?
+ token=token.refresh!
+ token=::OAuth2::AccessToken.new(token.client,token.token,{:expires_in=>token.expires_in,:refresh_token=>token.refresh_token}.merge(token.params))
+ end
+ token
+
+ end
+
end
+
+
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.