question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to use Magic with Electron app?

See original GitHub issue

✅ Prerequisites

  • Did you perform a cursory search of open issues? Is this question already asked elsewhere?
  • Are you reporting to the correct repository (magic-sdk)?

❓ Question

We are working on an Electron app and would like to use Magic. Currently, we can’t use magic-js in the render process of Electron due to the fact that as far as I know we can’t make Magic to redirect back to the Electron app (what should be the URI here?). At the same time Magic can’t be used from the main process of the Electron app because the window object isn’t present.

Right now, we are solving this by opening a browser tab for our user with our website in it. This website then loads the Magic script and tells user to check their email. Once user clicks on a link in their email they are redirected back on our website which tells them they can now safely navigate to the app.

await magic.auth.loginWithMagicLink({
  email,
  showUI: false,
  redirectURI: // <-- URI to an endpoint on our server
});

We would like to call loginWithMagicLink on the Electron frontend and then get the magic_credential parameter from the redirectURI on the server, from where we would (securely) send it to the electron app, where we would finish the login flow by calling loginWithCredential.

This is the error we get right now Screen Shot 2021-01-11 at 20 25 21

Is there currently a way to solve this?

🌎 Environment

Software Version(s)
magic-sdk 4.0.2
Browser Electron
yarn
Operating System macOS 11.1

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:20 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
smithkicommented, Jan 15, 2021

During the development, the Electron app has usually the localhost origin, but when the app is packaged the origin has the file:// protocol.

Hmmm, this could actually pose a problem using redirectURI because we rely on the URL origin to be consistent. I’ll raise this with our platform team so we can try to work through the potential security edge-cases. I’ll have something more substantial to share next week!

1reaction
ariborencommented, Jan 22, 2022

Hi @smithki - any update on this? Would love to be able to offer a unified redirect experience across our web, mobile and desktop (Electron) apps. Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Implement Auth on Electron with Magic
This tutorial shows how you can integrate Magic passwordless authentication into a desktop app using Electron. Electron is a JavaScript ...
Read more >
Building Electron desktop apps with React using Codemagic
In this article, we will create a sample app for monitoring and trading stocks using React and Electron and build it for macOS,...
Read more >
Electron.js LocalStorage magic or how to persist ... - YouTube
Alternatively, you can use SQLite or NeDB or any other Node. js based embedded databases, BUT they are actually too heavy to keep...
Read more >
electron.js HELP - MagicMirror Forum
var config = process.env.config ? JSON.parse(process.env.config) : {}; // Module to control application life. const app = electron.
Read more >
How to create a hybrid Electron app - Cameron Nokes
Load a web page into your Electron app but make it look like you're not just loading a web page. Don't expose Electron...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found