square / square-nodejs-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

401 Unauthorized issues

squibbleFish opened this issue · comments

Using the new SDK, I am getting the error

The `Authorization` http header of your request was incorrect or expired. The header value is expected to be of the format "Bearer TOKEN" (without quotation marks), where TOKEN is a valid access token (e.g. "Bearer ABC123def456GHI789jkl0"). For more information, see https://developer.squareup.com/docs/build-basics/using-rest-api#__set-the-headers__ .

Currently, using my sandbox connected to the latest API version. I have confirmed that the request headers being sent do contain the correct sandbox application id,

request: {
    method: 'GET',
    url: 'https://connect.squareupsandbox.com/v2/locations',
    headers: {
      'user-agent': 'Square-TypeScript-SDK/8.0.0',
      authorization: 'Bearer <>',
      'Square-Version': '2020-12-16',
      accept: 'application/json'
    }
  },

I've left it out for security purposes. This is a similar issue for all endpoints. Any help here would be appreciated.

I just realized that I should be using the token and not the application ID. My fault. Sorry about the unnecessary ticket.