Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Mosts FB Requests broken after upgrade to 0.5.0 #68

Open
eriksundelof opened this Issue · 8 comments

7 participants

Erik Timur Amirov Nicholas Hance Jake Thompson Claude William Wong Garay Erik Michaels-Ober
Erik

One of the main problems is that the automatic parser is not working anymore. The key :automatic does not exist from what I see making access_token requests pretty broken.

Line 127 in client.rb cannot work now from what I understand as the parsing is busted.
raise Error.new(response) unless response.parsed.is_a?(Hash) && response.parsed['access_token']

This makes integration with Facebook much more verbose than needed.

Secondly it seems as most token_url's now have to be added while calling which was not the case before.

Any updates on when these can be fixed?

Timur Amirov

I have same problems, when trying to access users's data recieve following trace:

/home/deteam/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/gems/1.8/gems/oauth2-0.5.0/lib/oauth2/client.rb:107:in `request'
/home/deteam/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/gems/1.8/gems/oauth2-0.5.0/lib/oauth2/client.rb:127:in `get_token'
/home/deteam/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/gems/1.8/gems/oauth2-0.5.0/lib/oauth2/strategy/auth_code.rb:28:in `get_token'
Nicholas Hance

I concur with this. I get the same error as DeTeam

Jake Thompson

Also seeing this

Claude

Dug a bit deeper:

OAuth2 is still a draft specification (right now at v22), and changes over time. One of the changes made was that the Authorization header containing the bearer token should not start with "OAuth " but with "Bearer ". See http://www.facebook.com/note.php?note_id=10150131557169413 (note: this article doesn't discuss any of Facebook specific stuff, just OAuth2 in general). The default name was changed in the gem in 5493f20 . Facebook however has not updated (yet) and still expects the header to start with "OAuth "

So basically this is not a bug.

To fix, simply pass the correct format to the AccessToken#initialize method

OAuth2::AccessToken.new(facebook_client, access_token_string, {:header_format => 'OAuth %s'})

One other thing I ran into, is that in 0.3.0 it was possible to do:

response_body_string = token.request(*args)

In 0.5.1, one needs to explicitly request the body

response_body_string = token.request(*args).body
William Wong Garay

@reinhrst this ok for me when I use:

token.get('/me')

But when I try to use:

token.post('/me/feed', :message => "hi, I'm posting a message from ruby")

Receive the same error:

OAuth2::Error: OAuth2::Error
from /Users/willywg/.rvm/gems/ruby-1.9.3-p0/gems/oauth2-0.5.2/lib/oauth2/client.rb:107:in `request'
Claude

OK, I don't think I ever tried it with posts... I don't have access to my facebook code anymore, so can't test it for you.

If I were you I would check if post indeed sends the correct header now (with OAuth in stead of Bearer).

Also, there are about a million other reasons why you may get an OAuth2::Error. Make sure you see what Facebook is actually sending you back (it may just be that your token is not allowed to post...)

Erik Michaels-Ober
Collaborator

Is this fixed in the latest version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.