Auth0 Universal Login with Electron

Hi there, I’ve seen a couple of Auth0 with Electron questions here so I hope this isn’t a duplicate. I have an Electron app and I am trying to use Auth0 Universal Login and am running into some issues. It seems like it hits auth0 and authenticates fine, redirects to my callback, then just loads my app again without authentication.

As I’ve read, Auth0 doesn’t support using file paths as a callback redirect. To get around this I spun up a node server in my main.js file:

         app.use(express.static(__dirname)); // Serve static files from the Parent Directory (Passed when child proccess is spawned).

 // go to callback component
app.use((req, res, next) => {
    res.setHeader('Access-Control-Allow-Origin', '*'); // Set this header to allow redirection from localhost to auth0
    next();
})

// Default page to serve electron app
app.get('/index', (req, res) => {
  logger.log(`serving from /index: ${__dirname + '/dist//index.html'}`);
  res.sendFile(__dirname + '/dist//index.html');
})

// Callback for Auth0
app.get('/auth/callback', (req, res) => {
  res.redirect('/index');
})

// Listen on some port
app.listen(8100, (err) => {
    if (err) logger.log('error starting server: ' + err);
    logger.log('HTTP Server running on port 8100');
});

Here is what I am seeing in my network tab when the callback returns.authorize and callback come back with a 302 Found status.

image

I think I am getting close but I’m not sure why the app is just getting loaded again without any authentication. If anyone has any insight into this I would greatly appreciate it. Thanks!

Hey there!

Sorry for such delay in response! We’re doing our best in providing the best developer support experience out there, but sometimes the number of incoming questions is just too big for our bandwidth. Sorry for such inconvenience!

Do you still require further assistance from us?