No route matches [POST] "/" error when pointing facebook canvas url to localhost:3000 - facebook

I'm trying to learn how to create a facebook canvas app using ruby/rails and develop it locally.
I create a new demo app and launch the server on my local machine at localhost:3000 then I create a new facebook app and point the Canvas URL to localhost:3000. Note that I check the sandbox enabled option and do not provide a secure Canvas URL.
As I try to access the app's Canvas page on facebook I see the following error displayed:
Routing Error
No route matches [POST] "/"
Try running rake routes for more information on available routes.
Note that when I access the app locally at localhost:3000 I do not get the error. I just simply see the usual default "Welcome Aboard" page from a newly created rails app.
Can anyone please pinpoint me to a solution or set of proper instructions on how to set up a local environment for fb canvas development? Any help would be much appreciated.

Your server or app isn't configured correctly to process the HTTP POST request from Facebook - I'm not familiar with how rails is configured but this blog post seems to offer a workaround: http://blog.coderubik.com/2011/03/restful-facebook-canvas-app-with-rails-and-post-for-canvas/
Note that the initial request to load your app will always be a POST request - this contains a signed_request value with data your app uses to know who the current users is - https://developers.facebook.com/docs/howtos/login/signed-request/ has more details

Related

Automatic Login with facebook using a subdomain from My App

I know this is an old answer but I think the context is different for my use case.
I am trying to log in with Facebook and in the configuration of my application in Facebook I have my web application. For example the URL of the site I have is website.com. However, I am actually using subdomains, in this way, my application generates subdomains belonging to my clients. For example, the URL of my client in my application
to login is: subdomain1.website.com The error message I get from Facebook is:
JSSDK Unknown Host domain: The domain where you host the Facebook Javascript SDK is not in the list of host domains in your app's Javascript SDK. Specify your host domain in the app dashboard login settings.
How can I login with Facebook using a subdomain? Obviously, I don't want to add the sub-domains every time a new customer comes to my application.
Pd: I thought that with adding to Allowed Domains for the SDK for JavaScript *.website.com
but that doesn't work.
I hope your answers, thank you.

How to setup an HTTP listener on localhost in a OSX App

I am trying to build an OSX application using swift and storyboard. I am implementing Google OAuth for the app. Following the google guide https://developers.google.com/identity/protocols/oauth2/native-app#sample-authorization-urls, I am opening a browser with the a loopback authorisation url (i.e. after signing in, it loopbacks to localhost where the url contains authorisation code and other meta data.
To give a better overview of how the authentication workflow works:
User selects authorise button in app
Browser opens up with an url like:
https://accounts.google.com/o/oauth2/v2/auth?
scope=email%20profile&
response_type=code&
state=security_token%3D138r5719ru3e1%26url%3Dhttps%3A%2F%2Foauth2.example.com%2Ftoken&
redirect_uri=http%3A//127.0.0.1%3A9004&
client_id=client_id
The google account chooser and permissions consent screen renders and prompts user to give permission..
Once user gives permission, the page redirects to localhost with the authorisation code or the error (when not permitted). The redirect url looks like:
http://127.0.0.1:9004/?code=auth_code&
scope=email%20profile%20openid%20https://www.googleapis.com/auth/userinfo.profile%20https://www.googleapis.com/auth/userinfo.email&
authuser=0&
prompt=consent
So now I want the parameter code in my app. Google document says I have to create an HTTP listener in order to get the parameters. So I want to setup an HTTP listener at that port (9004) and get the params. What HTTP library can I use to solve this problem?
I haven't tried to involve myself with any oauth library for osx and I want to implement myself but if there is a library which solves this problem with limited boilerplate suggest them.
Thanks.
I would recommend the AppAuth framework for macOS and iOS. It takes care of all of this for you, and includes an option to set up an HTTP server on the loopback interface.

Not able to create app for plaltform facebook canvas

I have a app ( web, ios and android ).I want to the create a Facebook canvas app where it will only show the first page of our web app.To achieve this.I created a Facebook canvas app in Facebook developer console.I filled the details which was required (Secure Canvas URL : https://example.com ,Mobile Site URL : https://example.com ) I am not sure what is secure canvas url meant so I put the link of my web app.But when open the canvas page
( https://apps.facebook.com/some_id).It is giving 405 Not allowed error.After digging I found out that Facebook is making a post request to my web app with a signed request ( not sure what it is ). How do I show my web page on facebook canvas page.Please explained to me how this things works and how can I achieve it.Thanks in advance.
Facebook loads app into the iframe by making a POST request to your app URL. You typically get a 405 Not allowed when your URL does not accept POST requests.
Many webspace providers have a setup where POST requests to “static” resources (such as .htm/.html files) are not allowed.
So you need to either change that in the webserver configuration (might be possible via .htaccess on an Apache; ask your server admin/support if you’re not sure), or you need to use a different “file type” for your app’s base URL that you want to load into canvas - for example, if PHP is available, the configuration usually allows POST requests to PHP scripts by default.

Windows Phone 8 C# facebook app registration

Hi I've created an app for Windows Phone 8 using the ContosoSocial Facebook login interface.
It uses the following call to do this:
FacebookSessionClient fb = new FacebookSessionClient(AppId);
fb.LoginWithApp("basic_info,publish_actions,read_stream", "custom_state_string");
This works fine when I use the default AppId but when I change it to the one given by Facebook following app registeration I get the following error:
Given URL is not premitted by the application cofiguration.: One or more of the given URL's is not allowed by the App's settings. It must match the website URL or Canvas URL, or the app domain must be a subdomain of one of the Apps domains..?
I've searched and this problem has come up on several occations and as far as I can work out it's to do with my app settings on Facebook.? Facebook asks for an App Domain which I've left blank as I'm not sure what this is or used for..? Do I need one..?
I've followed several tutorials Scrumptious but then all show a different app registration process on the screens than I'm faced with. A little research revealed that Facebook has recently changed the process which is making it even more confusing for me. I would appreciate some help here.
I want to create an app which will pull in a news feed direct into a panoramic item on the app's main screen.
Many thanks
EDIT: I've tried adding my web site URL to the app domain by I get the following error: This must be derived from Canvas URL, Secure Canvas URL, Unity Binary URL, Site URL, Mobile Site URL, Page Tab URL or Secure Page Tab URL. Check and correct the following domains: ***************
Below is the screen shot for configuring app:
Store ID, Application Name & Windows Store Beta ID removed, I'm now getting the following error:
App Not Setup: The developers of this app have not setup the app properly for Facebook Login. ?
Go to Advanced Settings in your developers.facebook.com/apps/ of your app and check that "Embedded browser OAuth Login" is enabled and set to Yes.

how to use FB.Connect.StreamPublish

from the scarcely documented FB api, I have thus far learned that I need to do the following to get the StreamPublish working:
I am making an iframe app
setup xd_receiver.htm. DONE.
put the FeatureLoader.js.php at the top of the body tag. DONE.
configure the api key and xd_receiver.htm. DONE.
configure the connect callback URL. NOT DONE -> what URL should I specify here?
I am unable to use the function. i have a specific link which shuld call for the FB.Connect.StreamPublish function.
can someone please explain the working of this by some example?
Check out this page for complete instructions on setting up Stream Publishing for iFrame apps (or Connect pages) using FB.Connect.streamPublish():
http://thetechnicalexperience.blogspot.com/2010/02/how-to-use-fbconnectstreampublish.html
In the facebook application settings, the description is:
Your Connect site's main URL.
And that is exactly what it is, the main URL for the site where your app resides.
If your app would've been a canvas app, you could use the FBJS function FB.streamPublish, but in an iframe app you will have to use the FB.Connect.StreamPublish.
More info at http://wiki.developers.facebook.com/index.php/Facebook.streamPublish
It seems that you have a conceptual error.
Iframe apps are canvas apps, NOT Connect apps.
Canvas apps are applications that work inside the Facebook site, eg: from a tab from your profile.
Canvas apps require you to configure a callback URL, which is the URL where your application resides. You shouldn't do steps 1-3 because Facebook will proxy the calls to your application so they can send your application session information about the user (through a POST or GET params).
Connect apps are external sites, like Digg, where you must do steps 1-3, but not step 4. Steps 1-3 are required to establish a communication channel with Facebook.
Please read http://wiki.developers.facebook.com/index.php/Connect/Setting_Up_Your_Site for a step by step guide for installing Connect in your site. After you are done with it, you can call FB.Connect.StreamPublish.