Deep index API test

Hi, when I try deep index allowance it returns Error:

Response body

Download

"JWT missing"
Response headers

content-length: 13 content-type: application/json; charset=utf-8

what Im missing?

1 Like

Hi @legenuspl,

You would require to generate a JWT token for authorisation when you make calls to the Deep index API.

Please run the api call -

For more information, please check out the docs over here – https://docs.moralis.io/deep-index-rest-api/deep-index-api

Hope this helps.

Do let me know if there’s anything else. :slight_smile:

How to pass json file i received from account/generateToken?

1 Like

Hi @legenuspl

  1. If you want to make calls using the interactive documentation, press the “Authorize” button at the top of the page, paste the JWT token you received from Generate token response in the “value” input and confirm by pressing “Authorize”.

  2. From Cloud Functions:

Moralis.Cloud.httpRequest({
  method: "POST",
  headers: { accept: "*/*" },
  url: "https://xxxxxx.moralis.io:2053/api/account/generateToken?key=yourmasterkey",
  body: "",
})
  .then(function (httpResponse) {
    const data = httpResponse.data;
    return data;
  })
  .then((data) => {
    const tokenJWT = `Bearer ${data}`;
    return Moralis.Cloud.httpRequest({
      method: "POST",
      mode: "cors",
      url: "yourUrl",
      headers: {
        "Access-Control-Allow-Origin": true,
        Authorization: tokenJWT,
        accept: "application/json",
        "Content-Type": "application/json",
      },
      body: yourBody,
    }).then(function (httpResponse) {
      console.log(httpResponse);
    });
  });
  1. From JS:
fetch("https://xxxxxx.moralis.io:2053/api/account/generateToken?key=yourmasterkey", {
  method: "POST",
  headers: { accept: "*/*" },
  body: "",
})
  .then(function (httpResponse) {
    const data = httpResponse.data;
    return data;
  })
  .then((data) => {
    const tokenJWT = `Bearer ${data}`;
    fetch(yourUrl, {
      method: "POST",
      mode: "cors",
      headers: {
        "Access-Control-Allow-Origin": true,
        Authorization: tokenJWT,
        accept: "application/json",
        "Content-Type": "application/json",
      },
      body: yourBody,
    }).then(function (httpResponse) {
      console.log(httpResponse);
    });
  });

Request URLs you can get in the interactive documentation.

Hope this helps :grinning:

1 Like