question

tvang avatar image
tvang asked David Marginian Deactivated answered

Node SDK Auth error

const Clover = require("clover-ecomm-sdk");

export default async (req, res) => {
  const clover = new Clover(process.env.CLOVER_KEY, {
    environment: process.env.DEVELOPER_APP_UID,
  });

  const payment = {
    currency: "usd",
    email: "sample@gmail.com",
    items: {
      amount: 1,
      currency: "usd",
      description: "Fireball 50ml",
      quantity: 1,
      tax_rates: { name: "Sale", rate: 1000000 },
    },
  };
  var myJSON = JSON.stringify(payment);
  let order = await clover.orders.create(myJSON)
};

I am using the Node SDK and trying to create an order. I am getting an error as follows:

CloverAuthenticationError
    at IncomingMessage.<anonymous> (C:\Users\tvang\Desktop\danneckersWebRedone\node_modules\clover-ecomm-sdk\lib\net\Resources.js:137:21)
    at Object.onceWrapper (events.js:297:20)
    at IncomingMessage.emit (events.js:214:15)
    at endReadableNT (_stream_readable.js:1178:12)
    at processTicksAndRejections (internal/process/task_queues.js:77:11) {
  raw: {
    type: '401 Unauthorized',
    message: undefined,
    headers: {
      'cache-control': 'no-cache, no-store, must-revalidate',
      pragma: 'no-cache',
      expires: 'Tue, 17 Sep 1991 10:00:00 PST',
      'content-length': '30',
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 14 Dec 2020 02:25:29 GMT',
      via: '1.1 google',
      'alt-svc': 'clear'
    },
    statusCode: 401,
    requestId: undefined
  },
  rawType: '401 Unauthorized',
  code: undefined,
  param: undefined,
  detail: undefined,
  headers: {
    'cache-control': 'no-cache, no-store, must-revalidate',
    pragma: 'no-cache',
    expires: 'Tue, 17 Sep 1991 10:00:00 PST',
    'content-length': '30',
    'content-type': 'application/json; charset=utf-8',
    date: 'Mon, 14 Dec 2020 02:25:29 GMT',
    via: '1.1 google',
    'alt-svc': 'clear'
  },
  requestId: undefined,
  statusCode: 401,
  message: undefined
}

is this because my ACCESS_TOKEN and ENVIRONMENT are not correct?

Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
David Marginian avatar image
David Marginian Deactivated answered

The sdk just makes API calls on your behalf, so, I would expect this to help - https://community.clover.com/articles/23744/resolving-401-unauthorized-responses-when-making-a.html. The permissions required for our ecomm calls can be reviewed here - https://docs.clover.com/docs/ecommerce-app-permissions.

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community