[SOLVED] 500 Internal server error, on login request with moralis/moralis-auth extension for firebase

Hi there,
I’ve followed this youtube tutorial, Everything was going good untill I got this 500 error.

I have installed and deployed the extensions, this 500 response comes in when I tried to login from my bowser.

Please, tell me the way to fix this issue.

1 Like

Hi @sharfuddin Can you please share the payload if the request?

If possible try checking the error logs in firbase. That can provide more details on the error.

Thanks for your reply! Here is the payload screenshot

Here is the Firebase Error logs in JSON

{
  "textPayload": "Unhandled error MoralisError [Moralis SDK Core Error]: [C0006] Request failed, Bad Request(400): Unauthorized\n    at RequestController.makeError (/workspace/node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:119:20)\n    at RequestController.<anonymous> (/workspace/node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:100:38)\n    at step (/workspace/node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:44:23)\n    at Object.throw (/workspace/node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:25:53)\n    at rejected (/workspace/node_modules/@moralisweb3/core/lib/controllers/RequestController/RequestController.js:17:65)\n    at processTicksAndRejections (internal/process/task_queues.js:95:5) {\n  isMoralisError: true,\n  code: 'C0006',\n  details: {\n    status: 400,\n    response: {\n      status: 400,\n      statusText: 'Bad Request',\n      headers: [Object],\n      config: [Object],\n      request: [ClientRequest],\n      data: [Object]\n    }\n  },\n  cause: [AxiosError: Request failed with status code 400] {\n    code: 'ERR_BAD_REQUEST',\n    config: {\n      transitional: [Object],\n      adapter: [Function: httpAdapter],\n      transformRequest: [Array],\n      transformResponse: [Array],\n      timeout: 10000,\n      xsrfCookieName: 'XSRF-TOKEN',\n      xsrfHeaderName: 'X-XSRF-TOKEN',\n      maxContentLength: -1,\n      maxBodyLength: -1,\n      env: [Object],\n      validateStatus: [Function: validateStatus],\n      headers: [Object],\n      url: 'https://authapi.moralis.io/challenge/request/evm',\n      params: {},\n      method: 'post',\n      data: '{\"chainId\":\"0x1\",\"address\":\"0xdBa96a456CEC0159B9276b61b7Dfb25451cB6045\",\"timeout\":60,\"domain\":\"localhost\",\"uri\":\"http://localhost:3000/\",\"statement\":\"To authenticate please sign this message.\",\"notBefore\":\"2024-06-18T11:02:27.712Z\",\"expirationTime\":\"2024-06-18T11:17:27.712Z\"}'\n    },\n    request: ClientRequest {\n      _events: [Object: null prototype],\n      _eventsCount: 7,\n      _maxListeners: undefined,\n      outputData: [],\n      outputSize: 0,\n      writable: true,\n      destroyed: false,\n      _last: true,\n      chunkedEncoding: false,\n      shouldKeepAlive: false,\n      _defaultKeepAlive: true,\n      useChunkedEncodingByDefault: true,\n      sendDate: false,\n      _removedConnection: false,\n      _removedContLen: false,\n      _removedTE: false,\n      _contentLength: null,\n      _hasBody: true,\n      _trailer: '',\n      finished: true,\n      _headerSent: true,\n      socket: [TLSSocket],\n      _header: 'POST /challenge/request/evm HTTP/1.1\\r\\n' +\n        'Accept: application/json, text/plain, */*\\r\\n' +\n        'Content-Type: application/json\\r\\n' +\n        'x-moralis-platform: JS SDK\\r\\n' +\n        'x-moralis-platform-version: 2.7.1\\r\\n' +\n        'x-moralis-build-target: node\\r\\n' +\n        'x-api-key: EjTod6yh1B1emr8sNOgUSCjRNUBWeBGSAO5nXdiLYt3GRlsccOHgxHNcv3qBBZkL\\r\\n' +\n        'x-moralis-product: firebase-auth\\r\\n' +\n        'User-Agent: axios/0.27.2\\r\\n' +\n        'Content-Length: 276\\r\\n' +\n        'Host: authapi.moralis.io\\r\\n' +\n        'Connection: close\\r\\n' +\n        '\\r\\n',\n      _keepAliveTimeout: 0,\n      _onPendingData: [Function: noopPendingOutput],\n      agent: [Agent],\n      socketPath: undefined,\n      method: 'POST',\n      maxHeaderSize: undefined,\n      insecureHTTPParser: undefined,\n      path: '/challenge/request/evm',\n      _ended: true,\n      res: [IncomingMessage],\n      aborted: false,\n      timeoutCb: null,\n      upgradeOrConnect: false,\n      parser: null,\n      maxHeadersCount: null,\n      reusedSocket: false,\n      host: 'authapi.moralis.io',\n      protocol: 'https:',\n      _redirectable: [Writable],\n      [Symbol(kCapture)]: false,\n      [Symbol(kNeedDrain)]: false,\n      [Symbol(corked)]: 0,\n      [Symbol(kOutHeaders)]: [Object: null prototype]\n    },\n    response: {\n      status: 400,\n      statusText: 'Bad Request',\n      headers: [Object],\n      config: [Object],\n      request: [ClientRequest],\n      data: [Object]\n    }\n  }\n}",
  "insertId": "667169440003db11ce052e52",
  "resource": {
    "type": "cloud_function",
    "labels": {
      "region": "us-central1",
      "project_id": "metamaks-moralis-test",
      "function_name": "ext-moralis-auth-requestMessage"
    }
  },
  "timestamp": "2024-06-18T11:02:28.252689Z",
  "severity": "ERROR",
  "labels": {
    "runtime_version": "nodejs14_20240609_14_21_3_RC00",
    "execution_id": "bx9ngzf5z492",
    "instance_id": "005b7087707097e006cd150ab15159c40fd4aceedbf6a195d7d2ca7d555f005726c0ecca6321d061c02716d50d9e511b121dcd08aa1fc5595ba8f0033630d1cacfc209"
  },
  "logName": "projects/metamaks-moralis-test/logs/cloudfunctions.googleapis.com%2Fcloud-functions",
  "trace": "projects/metamaks-moralis-test/traces/036d702aea760af48243ce9cbc09e86a",
  "receiveTimestamp": "2024-06-18T11:02:28.265913118Z",
  "errorGroups": [
    {
      "id": "CO-i34imhKvx_wE"
    }
  ]
}

The error log says Unauthorized error.

You will get this error if the API key used in the extension is incorrect. Can you please try updating the API key?

1 Like

Thank you for your support, Its working good now! :blue_heart:

2 Likes