Facebook App Used on Sites - facebook

I have a Facebook app. This app is a "Website with Facebook Login". However, I need to use it across several URLs. One for development, one for testing, and one for production. My urls looks like this:
Dev - http://localhost:[dynamicPortNumber]
Test - http://mysite.azurewebsites.net
Prod - http://www.mysite.com
Unfortunately, I cannot figure out how to allow multiple URLs to be associated with this app so that I can do end-to-end testing. Can someone please explain to me how to do this?

If you are using multiple top-level domains, the only way to handle this would be to create new App IDs for each instance (dev / test / prod).
However, if you have the freedom, using multiple subdomains in the same top-level domain will get you the result you are looking for. For example:
Dev: dev.mysite.com
Test: test.mysite.com
Prod: www.mysite.com
This will allow you to use the same Facebook App ID across all domains, as long as you use "mysite.com" as the App Domain.
Don't forget to add your site's URL in the "Site URL" box in the "website with facebook login" section!
NOTE: I have, in the past, had to add each individual subdomain in the app domain box in an app for it to function properly, but usually it's because I've made an error somewhere else.

Sadly there is no way to deal with the issue of different URLs for development, testing and production using a single Facebook App ID, you will have to create 3 different App IDs for each of the cases and use them at different places.
You can also check out Getting Started with Your Facebook App on Heroku that does the same.

Related

Facebook connect service for my customers without appid

I have more than few clients that would like to add facebook connect to their landing pages (managed by me). They are too many and not enough tech-savvy to manually create ad appid for each of them.
So my only solution is to usa my own appid to add facebook connect to all my clients websites, but as far as I know, Facebook doesn't allow to simply use the same appid on any domain.
How can I solve this? I can't find any documentation to solve my issue. Does anyone have a direction for me?
This has been discussed a couple o’ times before already – but I mostly commented on earlier questions, so let me write the whole thing up as a proper answer, for future reference.
[paraphrased] Multiple-client Facebook login via one single app id
Does anyone have a direction for me?
You probably rather don’t want to do that.
It is not really possible to run one simple app one multiple different domains.
As a workaround for only a few domains, people used to specify different domains for the different platforms – Website, Page Tab or Canvas App, plus Mobile alternative for Canvas – without actually using any of those platforms besides Website, which made the app usable on multiple domains as a website app. But since Facebook introduced their login/permission review process¹, you can’t do that any more – they expect you to present actual functionality on all platforms you have configured in your app.
You can kind-off use one single app for login on multiple domains – if you are willing to use only the server-side login flow, and to redirect users to one “main” domain (that gets specified as the app domain in the app settings) to login, and then from there back to the origin domain.
But this has several drawbacks:
It’s not what you’d call a “white label” solution. If your clients expect it to look as if users where logging in via “their” app, it should stay on their domain. Individual branding, in regard to stuff such as app name, app logo that shows in the login dialog, etc., would also not be possible. Additionally, app attribution – the link that shows up under content shared/posted via the app – would only link users back to the main domain, and not to your customer’s.
You would not be able to use the JS SDK for client-side API requests, or even just to embed it to render any of the FB social plugins that require an app id – the SDK checks what domain it is “running on”, and can not be tricked to accept a domain that is not specified in the app settings.
There could be privacy issues. An over-exaggerated example: Just because I as the app user decided to share my photos or videos I have on Facebook with your customer Our-Holy-Mother-of-Christ-Bakery.com, does not necessarily mean I want to share them with your other customer, amateurs-doing-all-kinds-of-nasty-stuff.xxx as well – but if they shared an app id for login purposes, I automatically would. Have fun writin’ the Privacy Policy (which is mandatory if you use FB login functionality, and FB also automatically checks if your app has got one) for that scenario ;-)
Finally, and most importantly: All your customers would be “sitting in the same boat.” If one of them, or in turn their website users, would publish spam via your app id, so that Facebook blocks it, login would not work any more for all of your customer’s websites. And if you decide only then, that setting up an individual app for each of your customers would be the better way to go, they would not be able to recognize their existing users any more, because of user ids being app-scoped since API v2.0 was introduced – so if users logged into this new app, that app would see a totally different user id. (And to rely on an email address as an identifier is risky, too, because you will not get one from the API for every user; for example if they registered using their mobile device.)
Edit: Plus, app/domain insights, as luschn mentioned in his answer.
¹ Yes, the review process has made it more laborious to set up multiple apps for multiple clients. But for apps that do the same stuff/use the same permissions in the same manner, you can refer to an earlier successfully reviewed app id to speed up the process a little. Also, screenshots of how f.e. posts made via the app look on timeline, and what UI components are used, as well as screencasts that you include in your submission could probably be used with little to no alteration.
Apps are not meant be used on several different domains, you will have to create a new App for each domain, i´m afraid. You can use the different platforms in the App settings to use different domains, but there are only a few so it´s pointless. Just create some screenshots and a tutorial for your clients, that´s how it is usually done.
Btw, it would be weird to authorize an App on a website, and the same App would allow you to be authorized on all other client websites. Also, insights are per App, so your clients may want to see their own insights and not the global insights of all domains together.
Many is not defined but i think for being a smart developer you need to create new app_ids for every project you need to use facebook connect. Just my opinion. It also allows you to monitor alot of stuff.

OAuth2, Facebook (multiple environments, localhost, azure)

I have the basic OAuth2 working with Facebook but it appears that I need to setup multiple apps in FaceBook to support. When I add platform, I can add only 1 web site and it has a URL. Seems like I need multiple facebook apps to support different environment.
I can configure it for local host and it works, I can reconfigure it for azure and it works, but I can never get both to work. I did configure multiple re-direct URIs to each environment.
Am I correct that I will need multiple facebook apps (appid and app secret), one for each environment?
Yes, you do need multiple apps for this to work under different domains. Facebook now offers the ability to create an app which is the "test version" of an existing app. You will still end up with different apps/app Ids so you need a way within your application to initialise the FB API with the app ID which is configured for the given environment.

Use same app on multiple domains

I'm creating a Social Media management webapp. This webapp will be used by our customers on there own sites (read, own domains). The webapp connects to a facebook app that we own, to allow them to manage there pages.
I'm using the "Website" platform for the app. During development I've had the "Site URL" set to my localhost url, and the "App Domains" set to localhost. This has worked fine.
However I now realise that this app will not always be run from localhost. It will be run from many differnt domains. I've read many posts about how its not possible to do this anymore, or at least the max is 5 domains by adding multiple platforms.
So how am I supposed to do this? Will I need to create an app on my profile for each customer/site? Will I have to create an app on each customers facebook account and link its app ID to our webapp?
The solution for this was not so bad.
Since AccessTokens are portable, so you can generate them on a single domain, and then use them to access the API from any page.
To do this, I have setup a single page on my own server (not customers server), whos domain is in my Apps Domains property. This page just has the facebook JS SDK, and some code to handle whether or not to show a login or a logout button. I embed this as an iFrame inside my webapp (that can run from any URL). I use
FB.Event.subscribe('auth.authResponseChange' function {});
to look for status changes, then use the the JS postMessage method to send the result of this to the parent of the iFrame, who then sends it to the server. This AccessToken can then be used anywhere.

Authenticating an App for Multiple Domains

I've built a tiny FB app whose purpose is to get the user's public profile URL. I have used the client-side authentication example provided, and it works just fine. I have also setup an application on Facebook.com so I can provide an APP ID. For this use, I have left App Domains blank, and made the app the type "Website with Facebook Login". And then I supply the "Site URL", the callback.
My trouble is that my web application runs across multiple domains. Individual customers have their own unique subdomain on our main domain. Do I have to create a new application for every single subdomain? It appears that way now, which would lead to hundreds — possibly thousands — of applications just to get a working callback URL for every customer domain.
Is there an easier way to do this?
For this use, I have left App Domains blank
You might want to reconsider that; especially you might want to read the explanation text for “App Domain” parameter that hovering over the [?] shows …

Can we have two domains in the App domain for facebook apps?

I've created an sample application for development and I've created another sample application with all the same properties except domain, since all the return_urls should be based on the domain. I'm using One version at my localhost and using other version in another test domain.
So whenever i copy all the code to my test domain, i need to change the app key , secret and return url etc..
What i need to know is whether its possible to add two or more domains for a single app and only change the return url without changing the app key, secret etc..??
Update:
Sorry i intended to say without changing app key, secret.. That was a typo mistake that changed the whole context of the question.
You can now create a Test App as a "child" app of your main app.
Similar to Test Users, Test Apps let you quickly create Facebook App IDs for use during the development, testing, staging or QA phases of the app development lifecycle.
Test Apps are like regular apps in that they have their own App ID and independent settings, but they offer a number of advantages for use during pre-production
A test app has its own URL and Domain, independent of the parent app.
No this is not possible. This has already been answered here: Allowing multiple domains for 1 Facebook App (like Tumblr)
You will need to set up a new facebook app for each distinct domain you create. Ideally you should have a configuration file for each domain in which you can store the app id/secret thereby preventing the need to edit it with each deploy.
Below steps help me to solve same problem.
Go to developers.facebook.com.
Click on your application and edit the settings.:
Add domains to that in the following form: example.com, example.org, subdomain.example.com (no http).
Save.