Hi Experts!
I am new to square payment gateway. I have a php website where i want to charge a card for payment. I have created account in square and created an application. Now i want to test in sandbox mode, so i do have sandbox access token and location-id so far I am successful in generating the form, but when i submit the form i get the below error:
category AUTHENTICATION_ERROR
code UNAUTHORIZED
detail This request could not be authorized.
in response, So kindly guide me through this issue.
FYI, i generated the form via below link:
https://github.com/square/connect-api-examples/tree/master/templates/web-ui/payment-form/basic
Regards,
Ali
Hey @ahsanali, I escalated your question to an API Specialist who confirmed that the AUTHENTICATION_ERROR message you received occurs when your Application ID and Personal Access Token do not match the information in your Developer Portal. Please make sure your Application ID and Personal Access Token are accurately updated in your sqpaymentform.js and your process-card files.
Feel free to also view our Developer Documentation for information on troubleshooting errors.
FYI, i copied the error from the response of below url via browser console
https://pci-connect.squareup.com/v2/card-nonce?_=1545914[Redacted]
Hey @ahsanali, I escalated your question to an API Specialist who confirmed that the AUTHENTICATION_ERROR message you received occurs when your Application ID and Personal Access Token do not match the information in your Developer Portal. Please make sure your Application ID and Personal Access Token are accurately updated in your sqpaymentform.js and your process-card files.
Feel free to also view our Developer Documentation for information on troubleshooting errors.
Thanks Helen,
You were correct!
My bad,
added sandbox access token instead of sandbox application id
😞
I also face same issue as below
Square payment error: Error calling ListLocations: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"This request could not be authorized."}]}.
please let me know how to make sandbox request authorized for testing
Hello, Helen.
I am stuck with problems and will be glad if you help me.
I am new to square and my problem is "request not authorized error".
I followed the steps of documentation, and if I click Pay button, then the javascript alerts "request not authorized error.".
Please help me.
Hi @Crystal-Moon! Thanks for reaching out. Make sure you have a completely verified and set up account that is approved to accept credit cards. If your identity has not been approved, then you will also receive that error.
@amchauhan Did you get a chance to read @Helen 's Best Answer above?
It looks like she reached out to the API team and posted the solution for this error there!
As per your suggestion I have follow all step still error remain same, at a time of listLocation menthod call
//get list of all locations
var listLocationsResponse = locationsApi.ListLocations();
above method throw exception as mentioned below
Square payment error: Error calling ListLocations: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"This request could not be authorized."}]}.
please let me know what can i do
Hello,
I have configure sandbox application id and sandbox access token of default authorized account and also set return url to square sandbox account but still when LocationApi call, this exception accour
Square payment error: Error calling ListLocations: {"errors":[{"category":"AUTHENTICATION_ERROR","code":"UNAUTHORIZED","detail":"This request could not be authorized."}]}.
we can not fetch sandbox account locations through api call please let me know how to resolve this error
Hi @amchauhan!
I reached out to the API channel and they said the error you're getting is due to having credentials mismatched or the base path URL not configured to the right environment.
Im having the same problem. I've double checked, and even reissued the key
I got fed up and went and tried it on your page https://developer.squareup.com/explorer/square_2019-12-17/oauth-api/obtain-token
Same error. I'm copying and pasting the id and key, as well as the code thats returned from /oauth2/authorize
that said, the dashboard has malfunctioned SEVERAL times. firstly it was not saving my Redirect URL, I'd add it then try it would error, id come back and it would be cleared out.
About 6 times i had to enter it before it would save, now thats working.
DUring testing why this unauth error is coming up, I "replaced token" this also doesnt reflect an update, had to log out then back in two times before it created a new one..
Anyway SAME problem..
curl https://connect.squareup.com/oauth2/token \
-X POST \
-H 'Square-Version: 2019-12-17' \
-H 'Content-Type: application/json' \
-d '{
"client_id": "sq0idp-Lno1QXpjx8Z2Avemg3orUg",
"client_secret": "DIRECTCOPYANDPASTE",
"grant_type": "authorization_code",
"code": "sq0cgp-B2KYptDrmgYoZ3Kii1M1dw"
}'
cache-control: no-cache
content-length: 70
content-type: application/json
date: Sat, 16 May 2020 23:02:53 GMT
{
"message": "Not Authorized",
"type": "service.not_authorized"
}
I'm also having the same issue. Is there any sort of permission that needs to be granted?
@ashc gave some insight provided by the API Team above. If you still need help, reach out to our Support Team. From there, your case will be escalated to our API Team.
Square Community