May 5, 2012
I was trying to make an existing app run as a Facebook App!
The following instructions/solutions will help you to access your http://localhost:3000/ through Facebook. In addition I would like to get the Facebook user with the fb_graph gem and save it in my database.
First of all you have to go to developers.facebook.com/apps to create a new Facebook test app.
The only important setting for now is this one:
I have also enabled the sandbox mode in the advanced settings, so that only I can access the Facebook app.
My app is really small so I’ve decided to only make an before_filter if the user uses Facebook to access my app:
My Facebook Model only has two attributes: identifier and access_token.
If there is no params[:signed_request] nothing will happen because it is not a Facebook Canvas. Otherwise an unauthorized user (every user has to give explicit permission to use the app) have to get redirect to authorize the app:
The authorize.html.erb
looks like this:
API Error Description: The specified URL is not owned by the application Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.
I got this error when redirecting to the authorize url. The problem was my canvas url! I’ve used this:
This does not work with the App ID, you have to specify an App Namespace in the basic settings – then the error will disappear, like so (App Namespace is „app_localhost“):