[SOLVED] Moralis Server Unauthorised Login

Hi,
I have some issues with my serverl URL being unauthorised.

I have just generated it on my computer in the last hour and is unable to authorise my metamask transaction with my Moralis server.

May I know if there are any ways to resolve this issue?

I have tried regenerating and recreating the server a few times today. !
Moralis Server|662x251

How are you not able to authorize your metamask transaction with your Moralis server.

Hi,
Per the picture in the previous message, my server is unauthorised.
Please see the error message per below:

// 20220614132617
// https://zjbr4kunhypk.usemoralis.com:2053/server

{
“error”: “unauthorized”
}

I have generated the server only an hour ago with a new server url and app id.

Do you have any suggestions in solving this issue of unauthorised error?

Are you using the correct appId in Moralis.start function?
It throws the same error in localhost, if the appId is wrong.

Hi,

I used the Moralis Server URL and Moralis Application ID for my application.
Please see the picture attached per below:


Could I check if it is the correct app ID?
I am unable to deploy the Metamask authorisation function in localhost and have traced it to this error.
Do you have any suggestions to solve the error?

What does your app code look like for connecting to Moralis? It should follow one of the examples here

I’m a bit confused e.g. in your first screenshot, you’re just loading https://zjbr4kunhypk.usemoralis.com:2053/server which will always return {"error":"unauthorized"} when you do that, this is normal for any server.

Hi,

I followed Step 1 and 2 using NextJS (npx create-next-app ) .
For Step 3, my code is per below:

import Head from 'next/head';

import { useRouter } from "next/router";

import { useEffect } from "react";

import { useMoralis } from "react-moralis";

export default function Home() {

  const { authenticate, isAuthenticated } = useMoralis();

  const router = useRouter();

  useEffect(() => {

    if (isAuthenticated) router.push("/dashboard");

  }, [isAuthenticated]);

 

  return (

    <div className="flex w-screen h-screen items-center justify-center">

      <Head>

        <title> Cypher Hash </title>

        <meta name="description" content="Create your own NFT" />

        <link rel="icon" href="/favicon.ico" />

      </Head>

      <button

        onCLick={authenticate}

        className="bg-blue-300 px-8 py-5 rounded-xl text-lg animate-pulse"

      >

        Login With MetaMask

      </button>

    </div>

  );
}

I am unable to get a pop up screen to authenticate MetaMask login although I have added the serverURL and appID (obtained from Moralis.io) under .env.local.
I am using the Mumbai testnet for the application.
My "Login with Metamask " button does not prompt a Metamask authentication page.

You can check here how to post code on forum:

Can you paste the code that uses the server url?

import Head from 'next/head';

import { useRouter } from "next/router";

import { useEffect } from "react";

import { useMoralis } from "react-moralis";

export default function Home() {

  const { authenticate, isAuthenticated } = useMoralis();

  const router = useRouter();

  useEffect(() => {

    if (isAuthenticated) router.push("/dashboard");

  }, [isAuthenticated]);

 

  return (

    <div className="flex w-screen h-screen items-center justify-center">

      <Head>

        <title> Cypher Hash </title>

        <meta name="description" content="Create your own NFT" />

        <link rel="icon" href="/favicon.ico" />

      </Head>

      <button

        onCLick={authenticate}

        className="bg-blue-300 px-8 py-5 rounded-xl text-lg animate-pulse"

      >

        Login With MetaMask

      </button>

    </div>

  );

}

Thank you for notifying me on the proper code posting method.

Please see the above for the code using the serverURL which is required for the Metamask authentication button to function.

I don’t see the server url set somewhere in that code.

Hi,
I have the error which was contributed due to a capitalisation error.

The code uses the serverURL and address for the Metamask authentication.

Thank you for all your help and clarifications.

1 Like

how can i change that to show the jason result

Can you please make a new topic with more details.