I’m trying to build a “RSVP to this event” action using the Facebook JS SDK.
All of our sites run on multiple subdomains (event1.example.com
, event2.example.com
) and I’m trying to setup a single Facebook app that will allow people to RSVP.
Ideally I’d like to be able to specify wildcard subdomains in the Valid OAuth redirect URIs
settings, but Facebook doesn’t seem to allow that.
Previous StackOverflow answers said that either just putting in the top-level domain or leaving that field blank would work (for example), but I always get the This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings
error.
Frustratingly, we shouldn’t need any sort of redirect callback to the server. I just want a short-lived token to post the event RSVP which should be possible client-side only.
Is there any way to accomplish this?
The options I can think of…
One app per subdomain We have 100s of subdomains, so creating Facebook apps for each isn’t going to work (plus that’s a manual process)
List all subdomains as redirect URIs it appears Facebook has a limit on the number of redirect URIs, plus this is also a manual process – there’s no API endpoint for adding these
Set the redirect URI via JS to our root domain and then just ignore the callback – this seemed promising, but calling FB.login
with a redirect_uri
param gave an error: When using FB.ui, you should not specify a redirect_uri.
Is there a way to do this without FB.login
?
Somehow let Facebook know we don’t care about those redirects at all — is there some other way to request permissions and make a JS API call without needing the oauth redirect?
Thanks in advance for any insights…
2
Answers
I don’t think so that there is a way you can login through Facebook on multiple domains, but there is a proper work-around to implement sign-in on multiple domains it’s called Single Sign On:
See:
https://www.sitepoint.com/single-sign-on-explained/
https://github.com/cubiclesoft/sso-server
We could use one specific sub domain/main domain itself to handle the facebook authentication
Every time pass the
state
which includessubdomain redirect uri
so that need not to adding sub domains to redirect uri list