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
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:
- Created 3 years ago
- Comments:20 (9 by maintainers)
Top GitHub Comments
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!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.