Moralis self-hosted + react native boilerplate + authentication + magic link

Hello! I am started using self-hosted moralis, becuase servers were stopped. So Authentication doesnā€™t work in react native boilerplate + with magic using .link() function. In Moralis Server it worked without problem. But in self-hosted I get an error:

warn: DeprecationWarning: auth.moralisEth is deprecated and will be removed in a future version. auth.moralisEth.enabled: true
error: Insufficient auth. {ā€œcodeā€:206,ā€œstackā€:ā€œError: Insufficient auth.\n at handleSessionMissingError (/Users/serousov/Desktop/projects/sleepin/parse-server-migration/node_modules/parse-server/lib/rest.js:172:11)\n at /Users/serousov/Desktop/projects/sleepin/parse-server-migration/node_modules/parse-server/lib/rest.js:165:5\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)ā€}

Hey there @expantano ,

It is likely that is is not something wrong with the self-hosted server as the RN boilerplate is an alpha product so thereā€™s a lot of bug in it. This is likely one of the bug in the boilerplate.

For building a mobile application, we recommend that you donā€™t use the Moralis Server as it limits your ability to build a scalable full stack mobile dapp. Instead, you should use our v2 SDK to build your backend then connect it with your frontend (React Native). This way you will have flexibility on what stack you are using in your application.

Let me know if anything confuses you or you need further clarification. I will be happy to assist you further :grinning_face_with_smiling_eyes:

I tried to use authentication custom with magic.link in react native app. I get authorized in magic link, then i get message result and after that I try to authenticate and got error.

Log and error:

[Thu Jan 05 2023 01:30:39.210] LOG [Error: Non ethereum enabled browser]
[Thu Jan 05 2023 01:30:39.559] LOG step 1, isLoggedIn: false
[Thu Jan 05 2023 01:30:56.605] LOG step 2: WyIweDc5M2M1MTU3NWQxNmZjMDM4YTFiOTQxZWExZmNiOGQ0ODhkZDE0OTUyMmM1ZGI4MmE3MDBkZDNjNmJmNjJiNWE3ODc0NTBhMmI2NDdlMTEyNjgzZTg0OWZhOGIwZWUxNmQwZmY3NmEwNDFjOThjYzVmNjEyNTljN2NlNjllMDU5MWIiLCJ7XCJpYXRcIjoxNjcyODcxNDU1LFwiZXh0XCI6MTY3Mjg3MjM1NSxcImlzc1wiOlwiZGlkOmV0aHI6MHhGQ0MyY2MyN0QwNWY1MEI0NjREQkJGRkE2MDVmNDM4ZTNiYjAzNTJGXCIsXCJzdWJcIjpcIlRYaGF2TlZaX2JLT1Zna0ltNlFiR
[Thu Jan 05 2023 01:30:56.774] LOG step 3, address: 0xfcc23c27d05f50b464dbbffa6dasd123
[Thu Jan 05 2023 01:30:57.220] LOG [Error: Non ethereum enabled browser]

Code:

Moralis.enableWeb3({
throwOnError: true,
provider: ā€œmagicLinkā€,
}).then((e) => console.log(e))
.catch((e) => console.log(e));
Magic.user.isLoggedIn().then(isLoggedIn => {
console.log("step 1, isLoggedIn: " + isLoggedIn);
if (isLoggedIn) {
successCallback();
} else {
confirmCallback();
Magic.auth.loginWithMagicLink({
email: email,
showUI: false
}).then(Ā® => {
console.log("step 2: " + r);
Magic.user.getMetadata().then(async m => {
let address = m.publicAddress;
let chainId = ā€œ0x38ā€;
console.log("step 3, address: " + address);
// Get message to sign from the auth api
const {message} = await Moralis.Cloud.run(ā€˜requestMessageā€™, {
address: address,
chain: parseInt(chainId, 16),
network: ā€˜evmā€™,
});

                // Authenticate and login via parse
                Moralis.authenticate({
                    signingMessage: message,
                    throwOnError: true,
                }).then(e => console.log(e))
                    .catch(e => console.log(e));
            });
        });
    }
}).catch((e) => {
    console.log(e);
    errorCallback();
});

This error means that there is no web3 wallet extension installed in your browser. You will need a wallet extension if you are choosing wallets over magic link email authentication.

Try installing the required wallet extension to fix this error.

And also include the provide parma value as magic link in this authentication function

provider: "magicLink",