x

Authentication error

 

Hi, 

My code is working fine using legacy sandbox details. But I am getting below error when I am using my sandbox details.
I am using PHP.

  1. category: "AUTHENTICATION_ERROR"
  2. code: "UNAUTHORIZED"
  3. detail: "This request could not be authorized."

 

 

https://ibb.co/KVZMSxF

1,765 Views
Message 1 of 6
Report
5 REPLIES 5
Alumni

@ArtWork - Hmmm, interesting. Sometimes you'll get this error if you're not fulling activated. 

 

I'm curious - have you completely set up your Square account to accept cards? From your Online Dashboard, check the bell icon in the top right corner to see if you have a message to finish setting up. 

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
1,620 Views
Message 2 of 6
Report

Hi Justin, 

Thanks for your response. 

Currently, I am using a development account for the square. so I don't have all the data to activate this account.
once development will complete I will replace my sandbox credentials with client production details.
Could you assist me with what should I do for using my current sandbox account?

1,598 Views
Message 3 of 6
Report
Alumni

Ah, gotcha @ArtWork

 

I ran this by our API team, and they think you may be using the wrong request url. When using the new sandbox, you have to change the url from "squareup.com"  to "squareupsandbox.com". Let me know if this helps or if you run into any issues. I'll keep the API Team on standby! 

Justin
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
1,568 Views
Message 4 of 6
Report

Hi Justin,

Thanks. According to your suggestion, I have changed the URL  for the configuration file as well js file.
Like : 
protected $host = 'https://connect.squareupsandbox.com'; and https://js.squareupsandbox.com/v2/paymentform
Now I am able to submit the form but still getting an exception error :
Exception when calling TransactionApi->charge:

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



1,546 Views
Message 5 of 6
Report
Square Community Moderator

Hey! I'm going to reply for Justin here:

 

So basically unauthorized errors means you're passing an invalid access token. Since you're trying to use sandbox, you need to make sure you’re passing in the sandbox access token.

 

When you go to https://squareup.com/dashboard/apps/my-apps, click on “Manage app”, make sure the bottom left corner says “Sandbox Settings” (and if not, click the toggle switch to go from “Production Settings” to “Sandbox Settings”), and then copy the “Sandbox access token”. You will need to pass this access token along with the Charge request.

 

Let me know if this helps!!

AshleyK
Community Moderator, Square
Sign in and click Mark as Best Answer if my reply answers your question.
1,530 Views
Message 6 of 6
Report