Having trouble trying to extend Facebook oauth token using graph_call #224

Closed
ghost opened this Issue Jun 14, 2012 · 2 comments

Comments

Projects
None yet
2 participants
@ghost

ghost commented Jun 14, 2012

PS: Posted this on stackoverflow as well. http://bit.ly/KqE63f

In reference to:

http://rubydoc.info/github/arsduo/koala/master/Koala/Facebook/GraphAPIMethods#graph_call-instance_method

http://developers.facebook.com/roadmap/offline-access-removal/#extend_token


My code looks something like this:

fb = Koala::Facebook::API.new(access_token)
fb.graph_call("/oauth/access_token", {"client_id" => app_id, "client_secret" => app_secret, "grant_type" => "fb_exchange_token", "fb_exchange_token" => access_token })

Although the return value contains the extended token but it is throwing MultiJson::DecodeError

MultiJson::DecodeError: 387: unexpected token at 'access_token=long-lived_token&expires=5184000]'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/json-1.6.1/lib/json/common.rb:148:in `parse'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/multi_json-1.0.3/lib/multi_json/engines/json_gem.rb:13:in `decode'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/multi_json-1.0.3/lib/multi_json.rb:65:in `decode'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/koala-1.3.0/lib/koala/api.rb:61:in `api'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/koala-1.3.0/lib/koala/api/graph_api.rb:421:in `graph_call'
from (irb):7
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/railties-3.1.3/lib/rails/commands/console.rb:45:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/railties-3.1.3/lib/rails/commands/console.rb:8:in `start'
from /usr/local/rvm/gems/ruby-1.9.2-p136@dotcloud/gems/railties-3.1.3/lib/rails/commands.rb:40:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

I suspect the ending ] that is causing the error. Not sure if this is a Facebook error or Koala error or mis-handling on my part. Appreciate if someone could help me out. Thank!

Contributor

bnorton commented Jun 16, 2012

Use

oauth = Koala::Facebook::OAuth.new(..., ...)
oauth.exchange_access_token(the_token)

instead.

Owner

arsduo commented Jul 21, 2012

Hi Brian, thanks for posting the answer!

John, feel free to reopen this that didn't solve your issue.

Best,

Alex

arsduo closed this Jul 21, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment