whazzmaster/fitgem — Issue #5: reconnect method results in "Invalid/expired user token"
Author: paulmmay
Created: 2012-02-25 22:41:27+00:00
State: open

Hello

I've followed along very closely with the code examples and the Wiki, and I'm having problems with the reconnect method.

I can successfully authorize my application the first time, then I'm updating my user to store the token and secret:

request_token = client.request_token
current_user.update(:token => request_token.token, :secret => request_token.secret)
redirect "http://www.fitbit.com/oauth/authorize?oauth_token=#{current_user.token.to_s}"

Now, when I go to reconnect I do this (the consumer key and secret are stored in my environment):

consumer_key = ENV['CONSUMER_KEY']
consumer_secret = ENV['CONSUMER_SECRET']
client = Fitgem::Client.new({:consumer_key => consumer_key,:consumer_secret => consumer_secret,:token => current_user.token,:secret => current_user.secret})
access_token = client.reconnect(current_user.token, current_user.secret)
puts client.user_info.inspect

in my terminal I get:

=> {"errors"=>[{"errorType"=>"oauth", "fieldName"=>"oauth_access_token", "message"=>"Invalid/expired user token: efd76cc6915c3ce345a43437c952403a"}]}

I don't see what I'm doing wrong - could this be a bug?