nov / fb_graph

This gem doesn't support FB Graph API v2.0+. Please use fb_graph2 gem instead.
MIT License
1.04k stars 191 forks source link

Long live session #309

Closed Nucc closed 11 years ago

Nucc commented 11 years ago

If I call the following URL, I get a long live session from facebook:

https://graph.facebook.com/oauth/access_token?client_id=APP_ID& client_secret=APP_SECRET& grant_type=fb_exchange_token& fb_exchange_token=EXISTING_ACCESS_TOKEN

If I use your example, I get a client error:

fb_auth = FbGraph::Auth.new(APP_ID, APP_SECRET) fb_auth.exchange_token! EXISTING_ACCESS_TOKEN => Rack::OAuth2::Client::Error

Now I don't know whether it's a bug or just the documentation is wrong.

nov commented 11 years ago

Use FbGraph.debug! https://github.com/nov/fb_graph/wiki/Debugging

Nucc commented 11 years ago

It seems the facebook misses the client id and client secret.

ruby-1.9.2-p0 > fb_auth = FbGraph::Auth.new(APP_ID, APP_SECRET)
ruby-1.9.2-p0 > fb_auth.exchange_token! EXISTING_ACCESS_TOKEN
======= [Rack::OAuth2] HTTP REQUEST STARTED =======
POST /oauth/access_token HTTP/1.1
Authorization: Basic NjA2NjE4MjM2MDM0MDgwOjJjYzExMGJkMzhhNjY0YzY5NDM2ZGRkZmEzMjI1OGE1
Content-Type: application/x-www-form-urlencoded
Content-Length: 250
Host: graph.facebook.com
grant_type=fb_exchange_token&fb_exchange_token=EXISTING_ACCESS_TOKEN
--------------------------------------------------
Status: 400 Bad Request
Access-Control-Allow-Origin: *
Cache-Control: no-store
Content-Type: application/json; charset=UTF-8
Expires: Sat, 01 Jan 2000 00:00:00 GMT
Pragma: no-cache
WWW-Authenticate: OAuth "Facebook Platform" "invalid_client" "Missing client_id parameter."
X-FB-Rev: 781736
X-FB-Debug: 4GbQavmgL2hhKiLdUjuaJ9z+4nxAa6Hbyi+R7PvnKOM=
Date: Thu, 11 Apr 2013 09:00:16 GMT
Connection: keep-alive
Content-Length: 0
{"error":{"message":"Missing client_id parameter.","type":"OAuthException","code":101}}
======= [Rack::OAuth2] HTTP REQUEST FINISHED =======
FbGraph::Exception: FbGraph::Exception
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/fb_graph-2.3.2/lib/fb_graph/auth.rb:59:in `rescue in exchange_token!'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/fb_graph-2.3.2/lib/fb_graph/auth.rb:54:in `exchange_token!'
        from (irb):4
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.1.0/lib/rails/commands/console.rb:45:in `start'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.1.0/lib/rails/commands/console.rb:8:in `start'
        from /usr/local/rvm/gems/ruby-1.9.2-p0/gems/railties-3.1.0/lib/rails/commands.rb:40:in `'
        from script/rails:6:in `require'
        from script/rails:6:in `
'
nov commented 11 years ago

Ah, updating fb_graph gem will solve the issue.

Nucc commented 11 years ago

Ah, yepp... Sorry, in Gemfile I defined it without version requirement and I thought this is the latest version. Ok, in 2.4.20 it works.

Invalid...