[SOLVED] How to use Moralis Auth on self-hosted server with web3uikit connect button

Hey guys,

I’ve set up a self-hosted moralis server, however when I try to log in, I receive the following error:
error: Moralis auth failed, invalid data.

I have used the following code to set up my server authentication: https://docs.moralis.io/docs/web3-parse-server-authentication

I believe the issue is I am not authenticating my user on the client side. From reading this forum, I believe I am supposed to use the code mentioned here on the client side (correct me if I’m wrong): https://docs.moralis.io/docs/connect-to-your-client#authentication

However, I am using the web3uikit connect button with my website, and I have not included the authentication code above on my front end (I assumed the connect button takes care of that for me, but maybe not).

If this is the problem, how can I use the web3uikit connect button to authenticate users? If this isn’t the problem, do you have any idea what the issue is?

Thanks!

So assuming that thi

The web3uikit code will need to be changed similar to that React client patch to use Auth API. I would recommend making an issue here so the developers can add this.

Otherwise you can adjust the ConnectButton code - you would have to build this and then use the updated library.

Another alternative is to use a Button with the same styles and features as ConnectButton (e.g. add native balance to the text) and use that directly with the code in that tutorial.

I decided to use the moralis authentication code and I am able to authenticate!

@alex i am shifting from normal moralis server to a self hosted one. For connect button i can use this code, but what about the logout button. If we have to logout from non self hosted server, we write this code
Moralis.User.logout() . Will this work?
Thank you

Moralis.User.logOut() should work normally. The React client uses the hook version of it.

Okay @alex thankyou!