Connecting to the Facebook API from Electron


Can anyone help me out with getting connected to the FB API? I’ve created a FB app and inserted my appID in FB.init( ). I keep getting the “Given URL is not allowed by the Application configuration: One or more of the given URLs is not allowed by the App’s settings. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App’s domains.” error. I’m assuming this is because I am running electron on localhost and I can’t figure out what the correct domain is. I’m probly just being dense here, but I’m stuck.

window.fbAsyncInit = function() {
    appId      : 'my-app-ID',
    cookie     : true,  // enable cookies to allow the server to access 
                        // the session
    xfbml      : true,  // parse social plugins on this page
    version    : 'v2.2' // use version 2.2

  FB.getLoginStatus(function(response) {


  // Load the SDK asynchronously
  (function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); = id;
    js.src = "";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));

Facebook login auth
Facebook OAuth web flow problem
Facebook OAuth web flow problem
Facebook api

Same problem here. Did you find any solutions for it?

I found this messenger app where a fb login is integrated. By checking the main js file ( it seems to be needed set certain properties for the ‘webPreferences’ object of your BrowserWindow:

webPreferences: {
// fails without this because of CommonJS script detection
nodeIntegration: false,
preload: path.join(__dirname, 'browser.js'),
// required for Facebook active ping thingy
webSecurity: false,
plugins: true

I’m still getting an error that ‘Given URL is not ping?client_id=MY_ID&domain=&origin=1&…:1 Given URL is not allowed by the Application configuration:’ So it seems that i need to configure some special stuff on the facebook settings page, but i can’t find what exactly. Tried already almost every possible setting :confused:

MY_ID is of course a real app id :wink:


Is there a solution for this?


redirect_uri. The URL that you want to redirect the person logging in back to. This URL will capture the response from the Login Dialog. If you are using this in a webview within a desktop app, this must be set to You con confirm that this URL is set for your app by going to the App Dashboard, clicking Facebook Login in the right-hand menu, and checking the Valid OAuth redirect URIs in the Client OAuth Settings section.


Hi, I setup the redirect_uri as mentionned, but I’m still getting error message about the url domain…
Can’t set the domain to and I really don’t see what I can use as domain.


Did you solved this problem?


You cannot use JavaScript SDK on building a desktop application. Alternatively, you should build login flow manually using browser redirects. Details are shown in the following link.(
Note that redirect_url must be set to and this url must be included in the Valid OAuth redirect URIs in the Client OAuth Settings that appears after adding Facebook Login by clicking Add Product on the left side menu.


Can somebody provide any examples please !


Here’s how I did it: