Example question title: Why am I getting a 401 unauthorized?

This is an example question to guide you as you start asking questions!

  • Make sure your title and description are descriptive and include what you are trying to achieve and what you’ve already tried.
  • Make sure you provide what SDK or API you’re using along with the version number.
  • Make sure you include environment-specific information such as OS / Language Runtime / etc.
  • Make sure you are not asking a duplicate question. Repeat questions water down information across multiple posts and create additional work for the community. Always check to see if your questions have been asked previously.

The 401 unauthorized error is typically due to an invalid (or possibly even missing) access token made in your API request. Please be sure that your request includes a valid access token in the Authorization header. Please also note that if you’re using sandbox, that the domain should be “https://connect.squareupsandbox.com” instead of “https://connect.squareup.com”, which can also cause this error. For more information about setting this header, take a look at our doc site.

Hello, I am having this exact error and all my credentials is correct.

I have a form on my WordPress built website

https://handsfreeluggage dot com/appointment-booking/

in which I am trying to use Square to recieve payment.

However, when I try to pay it pops a “REQUEST NOT AUTHORIZED” error as I input the following test card details.

Test Credentials :
Card Number : {{redacted}}
Card CVV : 111
Card Expiration : 08/2024
Card Postal Code : 44101

On my backend section on my website in Square, I used the following test credentials.

sandbox-sq0idb-SKf5r91WoDy4dcCkbccXsA
Location ID :- LN0ZPJ72GAFD3

Please help !!!

i have also this issue

Response body:
object(stdClass)#7 (1) {
[“errors”]=>
array(1) {
[0]=>
object(stdClass)#6 (3) {
[“category”]=>
string(20) “AUTHENTICATION_ERROR”
[“code”]=>
string(12) “UNAUTHORIZED”
[“detail”]=>
string(37) “This request could not be authorized.”
}
}
}

url = https://connect.squareupsandbox.com
$access_token = ‘EAAAENq8uO8rgmjYf70V_F9oxL-CavCN2gbL***’;
var applicationId = “sandbox-sq0idb-eW2hqYxp*******”;
$location_id=‘LGKWYPQ***RE’;

:wave: @hussainmd I took a look at your account and see successful API calls. Are you still running into this error? Also I see that you are calling the deprecated Transactions API. Is there a reason that you are using that API? :slightly_smiling_face: