Magic Link Authetntication

Please post any Magic Link specific questions down below.
We are here to help!

Links that may be of use:
Magic Link Docs: https://magic.link/docs
Magic Auth With Moralis: https://docs.moralis.io/moralis-server/users/crypto-login/magic

1 Like

Sir
Is it possible to add username and also fullname
Using this magic SDK

Hello! Does anybody know if using the Magic Link auth provider we get on the promise the same result as if we were using Magic Link without Moralis?

Magic link always returned a Decentralized ID token on response after login so we could verify this login on server side.

Reading the Moralis SDK from Github looks like Moralis always return the user so we donā€™t have de Decentralized ID token from magic link

Magic link creates a user in your database where you can add user name and any other data

1 Like

Exactly you get the User and can start working on your app without worrying the underlying mechanism

Moralis ensures that no matter what authentication method you use - you get a Moralis User back

1 Like

But how can we get that Decentralized ID? I want to use it to verify magic link authentication on server side. If Moralis is not returning me this data that Magic Link was already returning is there a way to obtain it? Can we still use the magic link client sdk even if we login through moralis?

No using the Magic integration you get the User object that is created in Moralis DB and thatā€™s it

Moralis already verifies the login and ties it to a User

Technically you could fork Moralis SDK on GitHub and change it to return more data or just use Magic without Moralis

I donā€™t understand your use case - because the idea with using Moralis is not having to verify anything on the backend yourself

1 Like

I have a already created database where I create users once they login, it isnā€™t a new app which I can only rely on Moralis DB. On Magic official links they encourage people to login client side and then send the Decentralized ID to the backend in order to use Magic Admin SDK to verify that the Decentralized ID is valid. Once the Magic Admin SDK verifies this you can safely create a user on database if it doesnā€™t exist.

Thatā€™s the general use case and what most of people is using with already created apps that are using magic link.

I know that magic link client SDK exposes a method to get the decentralized ID so, if Moralis is not returning it, can we use the magic Client SDK to obtain it?

The reason of all of that is to donā€™t broke already existing functionalities and validations on existing apps.

Ok I understand - then I think itā€™s best to use magic directly without moralis integration

Moralis integration is for developers that have their tech stack in moralis and want an easy integration where all steps are managed and you donā€™t have to worry about the underlying mechanism

The thing is, we are thinking on out business to add Moralis only for blockchain related data so we would like to create users is Moralis DB too in order to save on Moralis DB everything about their balances, NFT and so. Apart from Moralis DB we want to keep our current DB for other non-blockchain related data.

Do you recommend us to create manually the user on Moralis DB once we verified the Decentralized Id on server or do you think of any better approach?

Iā€™m not sure you need a user profile in Moralis in this case

I think you can use Moralis to sync transfers of different user addresses (see ā€œwatch address from codeā€ section https://docs.moralis.io/moralis-server/automatic-transaction-sync/historical-transactions) and just get real time transfer data and send to your own backend (https://youtu.be/PEILxU53-Zs)

To get the NFTs of the user the best way is to use Web3API https://github.com/nft-api/nft-api

You can then insert the NFT data into your own database

Please create a new thread if you want to discuss this further so we keep this thread in topic only about Magic integration :raised_hands:

1 Like

Yeah! Thank you so much Ivan, hopefully this thread helps other people with already existing Magic Link environments that have similar questions.

3 Likes

Iā€™ve integrated Magic Link and here are my findings so far:

  • at first it was unclear where my wallet is. How do I access it outside of Moralis? I think you canā€™t and need to build your own little UI. Still feels very weird, no confirmations, no information about gas cost, total cost. It just goes and email arrives fast. Perfect for the noob user, scary for the experience crypto user haha. I donā€™t know how I feel about that yet, but itā€™s definitly magic!

  • iā€™m wondering if just using an email address doesnā€™t lead to a lot of spam when someone knows your email?

  • the created Moralis User doesnā€™t include the userā€™s email address, which is great for privacy. But Iā€™m currently unsure how to use the Magic.user in Moralis, for example to get user metadata:
    const { email, publicAddress } = await Magic.user.getMetadata()
    So in my case, I cannot send them a welcome email. I would like to create a user opt-in during onboarding.

  • it can take long for the login modal to show anything, so you need to build at least some loader yourself to let the user knows something is coming. Maybe itā€™s caused by the errors i get on locahost. Some forage-ing going on, but it all works:

  • would be helpful to some to add all options to Moralis SDK interface, for Magic locale and testMode are missing and cannot be set. Also in Web3Auth most options are missing sadly.

  • setup also should support extensions like oAuth for social logins https://magic.link/docs/login-methods/social-logins/integration/oauth-implementation/web, currently on the email option is provider in Moralis SDK with default a few basic setup options.

  • thereā€™s still an issue i encountered that makes it not usable. Can cannot refresh the page and reinstate the Moralis web3 provider without authenticating again, see Wallet Connect,Web3Auth & Magic Link does not restore session when user is already logged in

let me know your thoughts and experience.

:woman_mage:

1 Like

Hello guys! Iā€™m using Magic Link to authenticate. But how do I change the network to BSC(mainnet)? Is it the same way like the other login methods by specifying network: "bsc" or something elseā€¦ Because other login methods have chain: parameter and Magic Link has network: parameter! So I wonder asigning "bsc" to network: will work or not! Need some clarification here please!

Hey,
its BSCOptions
Check this link: https://magic.link/docs/advanced/blockchains/binance-smart-chain#smart-chain

Iā€™ll try and get back to you mate! Thanks!

1 Like

Is support for SMS login coming? Or should we integrate with magic directly for this functionality?

You should integrate Magic Link directly for SMS login atm

we donā€™t support that integration now

mAdmin.token.getIssuer() method returns Malformed token error for a valid token. I can share the token if necessary. Donā€™t know whatā€™s wrong here. Please help

mAdmin.token.getIssuer()

Where is that code from? Can you post more details.