Issues switcghing to sandbox account/environment

I have been developing an application and using my production account.

I need to start testing the creation of orders and then payments, for this I created a new sandbox account.

I am filtering all of my SDK requests to a specific location ID as this is an online ordering platform when I want to limit available items to have an online and physical store location.

In the production application, this was working ok.

However, since switching to the sandbox the SDK requests to the catalogue are returning a 200 but not producing any items.

I exported all of the items from the production catalogue and imported them to the sandbox one. I created a new “online” location in the sandbox account and made sure all items are available at this location.

My application now uses the sandbox online location ID and pretty much everything fails except for a call to get the categories.

As I mentioned earlier no catalogue items are returned anymore and when I do try and create an order (after removing the location ID from the request) I get an authorization error like below:

{"errors": [{"code": "FORBIDDEN","detail": "Not authorized to access orders with location_id=LFPBZD73080G7","category": "AUTHENTICATION_ERROR"}]}

This is how I am initializing the client SDK

const squareClient = new Client({
  environment: Environment.Sandbox,
  accessToken: params.SQUARE_ACCESS_TOKEN_SANDBOX,
  customUrl: "https://connect.squareupsandbox.com",
});

const { catalogApi, ordersApi } = squareClient;

What’s your application ID? :slightly_smiling_face:

HI @Bryan-Square the application ID is: sandbox-sq0idb-eERC5hL431-5C4r61pJjEQ

Is the access token your using the access token from the application or are you using the access token from clicking on the three dots on the Square Sandbox account you created?

When I tested with the one from the View detail is was able to get all the catalog objects. :slightly_smiling_face:

1 Like

Ok so with that token yes everything is working.

Previously I was using the one from the application page after selecting sandbox

Great! Glad to hear it’s working as expected. :slightly_smiling_face:

I am having the same issue but for production. I created a backend server that communicates to the Square API. It works fine for retrieveing the data (catalog api), but not when creating a cart (orders api).

My square app id is sq0idp-pb02e8UVJuCvgMankWy_yg.

I took a look at your API Logs and your using your sandbox location_id in your production CreateOrder request. You’ll need to use a production location_id in production. :slightly_smiling_face: