ondc-node icon indicating copy to clipboard operation
ondc-node copied to clipboard

Unauthenticated issue

Open SantoshKumarRavi opened this issue 2 years ago • 0 comments

i have used correct private key of my buyer app, i am getting Unauthenticated err. i am new to ondc network.

and this is my code

  const instance = new ondc.ONDC({
    host: "https://ref-app-buyer-staging-v2.ondc.org/clientApis/v1",
    bapId: "xxx.com",
    bapUri: "https://xxx",
    country: "IND",
    city: "*",
    ttl: "P1M",
    uniqueKey: xxx,
    domain: "nic2004:52110",
    subscriberId: "xx.com",
    signingPublicKey: "xxxxxx",
    encryptionPublicKey:
      "xxxxxxxxxx",
    privateKey:
      "xxxxxxxxxxxxx",
  });
  let body = {
    item: {
      descriptor: {
        name: "ABC Aata",
      },
    },
    fulfillment: {
      end: {
        location: {
          gps: "12.4535445,77.9283792",
        },
      },
    },
  };
  // apiKey is sent in Authorization Header
  const headerStr = await instance.createAuthorizationHeader(body);
  instance.apiKey=headerStr
  const response = await instance.search(body);
  console.log("response", response);
  res.status(200).send(response);

Can u help me to overcome this issue ?

SantoshKumarRavi avatar Oct 30 '23 04:10 SantoshKumarRavi