Moralis auth failed, invalid data NODE.JS [Unity]

Hello! I have been using Moralis v1 SDK with Unity, but now servers by Moralis are deprecated and in order to continue supporting the project it was proposed to create a self-hosted parse server which I did. I deployed it to production on Heroku platform and launched it successfuly… BUT when I try to connect my Unity app with it there’s error occurs:

Unity SDK needs these two params: Dapp URL and Dapp ID, so in first line I paste Heroku server URL and in second I paste my app id that I set in the project (from documentation: set up parse server locally, demo-project) on NODE.JS, not Vanilla Javascript or React (writing it because came across topic on the forum with those two languages)

I’ve installed it and changed necessary variables and uploaded it to Heroku but now I stumble upon this error, help me, I beg you very much :pray: :pray: :pray:

Hello,
How did the message that you have to sign look like? it had a timestamp as a number at the end of the string or not?

You also have to adapt the code that gets the message

maybe this thread helps you: Using Unity SDK with self-hosted server

In demo project I can’t find code that I have to change as says the documentation (Authentication)

As for the message i don’t really know because all using part is inside Unity project, it just generate this message above.

Thanks for thread that you provide, I will check

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// Note: do not import Parse dependency. see https://github.com/parse-community/parse-server/issues/6467
/* global Parse */
const moralis_1 = __importDefault(require("moralis"));
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateAuthData(authData) {
    const { signature, data } = authData;
    return moralis_1.default.Auth.verify({
        message: data,
        signature,
        networkType: 'evm',
    })
        .then((result) => {
        const authenticated = result.toJSON();
        authData.chainId = result.result.chain.decimal;
        authData.nonce = authenticated.nonce;
        authData.address = result.result.address.checksum;
        authData.version = authenticated.version;
        authData.domain = authenticated.domain;
        authData.expirationTime = authenticated.expirationTime;
        authData.notBefore = authenticated.notBefore;
        authData.resources = authenticated.resources;
        authData.statement = authenticated.statement;
        authData.uri = authenticated.uri;
        authData.moralisProfileId = authenticated.profileId;
    })      
        .catch(() => {
        // @ts-ignore (see note at top of file)
        throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Moralis auth failed, invalid data');
    });

In this line I get the error: throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, ‘Moralis auth failed, invalid data’);

Hi @asd37, welcome to the community. I will look into this and get back to you.

Cheers,

David

Hi @dpradell ! Looking forward to your reply

Hello again. It did login after signing and now seems to be working fine, but… there are some bad request errors retrieved from leaderboard, take a look please:


I really need your help, pleeaasee

do you know what was the request that was invalid? is that error affecting functionality?

Only leaderboard working, for all other functions it’s throwing these errors

I think it was request we send for checking when we are logging in.

It looks like it says that it didn’t expect the subdomain parameter

How is this related and how to fix that?

I don’t know, I’m not familiar with Unity, we’ll have to wait for someone that is familiar with Unity.

1 Like