Error when parsing signed request #127

Closed
maxiperezunlam opened this Issue Sep 28, 2011 · 4 comments

Comments

Projects
None yet
2 participants

When i try parse the signed_request throw this exception

FbGraph::Auth::VerificationFailed (Signature Invalid)

def find_auth
if params.has_key? :signed_request
session[:signed_request] = params[:signed_request]
@auth = authorizor.from_signed_request params[:signed_request]
@LiKED = Canvas.parse_signed_request(configatron.fb_authentication_app_secret, params[:signed_request])['page']['liked']
else
@auth = authorizor.from_signed_request session[:signed_request]
@LiKED = Canvas.parse_signed_request(configatron.fb_authentication_app_secret, session[:signed_request])['page']['liked']
end
end

def authorizor
FbGraph::Auth.new(configatron.fb_authentication_app_key, configatron.fb_authentication_app_secret)
end

Owner

nov commented Sep 28, 2011

This type of issues are hard to debug on my side with this information.
Same solution here.
https://groups.google.com/forum/#!topic/fb_graph/Bg9Z2iZvEHU

Excuse me This issue was produced by a bad configuration. Now i can parse signed_request, and ask permissions however i have two problems.

The first is how could redirect (inside tab application) to callback url. should I modify my configuration?.

The second is about access_token

In callback action i should parse and the save the access_token

def authorize
@auth.client.authorization_code = params[:code]
access_token = @auth.client.access_token! # => Rack::OAuth2::AccessToken
@facebook_user = FbGraph::User.me(access_token).fetch # => FbGraph::User
#MORE CODE
end

However throw a error in @auth.client.access_token!

OAuth:Client::Error

Oauth::Exception => "Missing redirect uri parameter"

Owner

nov commented Sep 29, 2011

In my sample, you can find Facebook.auth(callback_facebook_url).client in facebook_controller.rb
https://github.com/nov/fb_graph_sample/blob/master/app/controllers/facebooks_controller.rb

It sets redirect_uri to the client and use the URL as redirect_uri when client.access_token! is called.

PS.
If you want to know more details of OAuth2 flow, call FbGraph.debug! and set FbGraph.logger = Rails.logger in config/initializer/fb_graph.rb or somewhere.
Then you can see the raw HTTP request & response.

Ok, thank you very much.

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