Hi everyone,
I am building an internal integration for my own shop to sync daily sales from Square POS to a Google Sheet using Google Apps Script.
I am receiving the following error when making a request to https://connect.squareup.com/v2/orders/search:
“Error: You have insufficient permissions to perform that action.”
The Weird Part (Troubleshooting so far):
The credentials work perfectly for other endpoints.
I tested the exact same Production Access Token and Location ID in a script to fetch my inventory (using v2/catalog/list and v2/inventory/counts), and it returned data successfully.
The 403 error only happens when I attempt to access the Orders API.
My Setup:
-
I am the Owner of the Square account.
-
I created the App in the Developer Dashboard myself.
-
I am using the Production Access Token (Personal Access Token), not OAuth.
-
I have verified that the dashboard toggle is set to “Production” and the token starts with EAAA.
The Failing Code:
I am using Google Apps Script (UrlFetchApp). Here is the request structure that fails:
codeJavaScript
const url = 'https://connect.squareup.com/v2/orders/search';
const payload = {
"location_ids": ["MY_LOCATION_ID"],
"query": {
"filter": {
"state_filter": {
"states": ["COMPLETED"]
},
"date_time_filter": {
"closed_at": {
"start_at": "2023-10-25T00:00:00.000Z",
"end_at": "2023-10-25T23:59:59.999Z"
}
}
}
}
};
const options = {
"method": "post",
"contentType": "application/json",
"headers": {
"Authorization": "Bearer " + "MY_ACCESS_TOKEN",
"Square-Version": "2023-10-20"
},
"payload": JSON.stringify(payload),
"muteHttpExceptions": true
};
The Question:
Since this is a Personal Access Token for the account owner, shouldn’t it have global permissions? Why would it allow me to read Inventory/Catalog but block me from reading Orders?
Is there a manual scope setting I need to toggle in the dashboard even for Personal Access Tokens?
Any guidance would be appreciated. Thanks!