Reputation: 1480
My problem is on facebook callback url. I am using fbgraph gem on Rails 3.0.
I ask for extended permissions on my tab application. So in the callback I wait code parameter and access_token.
I extract this code from fbgraph official GIT repository.
def authorize
begin
@auth.client.authorization_code = params[:code]
#In access_token line should return me access__token but throw a error message (see below)
access_token = @auth.client.access_token! # => Rack::OAuth2::AccessToken
@facebook_user = FbGraph::User.me(access_token).fetch # => FbGraph::User
#MORE CODE WITHOUT IMPORTANCE
redirect_to :controller => "dashboard", :action => "index"
rescue Exception => e
logger.info(e.message)
end
end
Throw this error message:
Rack::OAuth::Client::Error # => @status = 400, Message => Missing redirect uri
Please I need help quickly. Excuse me and thanks in advance
Upvotes: 0
Views: 1503
Reputation: 2606
I'm using the fb_graph gem which is similar. In order to get the access_token you also need to supply the callback URI - this is the fb_graph version:
client.redirect_uri = "http://your.callback.uri"
client.authorization_code = params[:code]
access_token = client.access_token!
Update:
Looking at the fbgraph gem documentation I think you need to replace these two lines:
@auth.client.authorization_code = params[:code]
access_token = @auth.client.access_token!
With this:
access_token = @auth.client.authorization.process_callback(params[:code], :redirect_uri => callback_url)
To be honest I looked at using the fbgraph gem but the documentation was so bad that I switched to fb_graph instead which is similar and actually has some useful examples in the documentation.
Upvotes: 1