# Sandbox credentials

**URL:** <https://developer.squareup.com/forums/t/sandbox-credentials/4527>\
**Category:** Questions\
**Tags:** payments-api, sandbox\
**Created:** [December 8, 2021, 10:44am UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527 "2021-12-08T10:44:05Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 8, 2021, 10:44am UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/1 "2021-12-08T10:44:05Z")

</div>

Hello, I have created a test application which is currently in sandbox mode. When I am trying to charge a test card using the connect API I am getting Not Authorized error.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 9, 2021, 5:04pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/2 "2021-12-09T17:04:05Z")

</div>

👋 When you get the not authorized error that means that the credentials or the environment isn’t correctly configured. 🙂

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 10, 2021, 5:04pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/3 "2021-12-10T17:04:39Z")

</div>

Hello,  
I am using the following set of credentials -  
Location id : LY0HVM1W81FNS  
Sandbox Application ID : sandbox-sq0idb-hSa1tfIZy04h4QOYgWYiww  
Sandbox Access Token : ACCESS\_TOKEN

and here is a request I sent to the charge API -  
Array  
(  
[card\_nonce] =\> cnon:CBASEBqqMQwGD10AKt9h-gWIogU  
[amount\_money] =\> Array  
(  
[amount] =\> 1100  
[currency] =\> USD  
)

```
[idempotency_key] => 61b386a31c959

```

)

This is the response I am getting as an error -  
SquareConnect\ApiException Object  
(  
[responseBody:protected] =\> stdClass Object  
(  
[errors] =\> Array  
(  
[0] =\> stdClass Object  
(  
[category] =\> AUTHENTICATION\_ERROR  
[code] =\> UNAUTHORIZED  
[detail] =\> This request could not be authorized.  
)

```
            )

    )

```

My account has been configured for sandbox environment.  
Is the charge API itself different for sandbox and live environment?  
Thanks,  
Jitendra

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 10, 2021, 6:31pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/4 "2021-12-10T18:31:45Z")

</div>

In the future please don’t share the access token. Those are secrete. Also what environment is the client configured to? Is it production or sandbox?

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 13, 2021, 11:46am UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/5 "2021-12-13T11:46:47Z")

</div>

OK I will keep that in mind.  
It is configured for Sandbox environment

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 13, 2021, 5:32pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/6 "2021-12-13T17:32:23Z")

</div>

Everything looks to be correct. The payment request is formatted correctly and the `source_id` is generated from the application ID you provided in the sandbox environment. The only thing that can cause this error is that the client isn’t correctly configured. If you try to make another API call to `ListLocations` with your client do you get the same error? Also if it succeeds is the returned location this one `LY0HVM1W81FNS` from the payment request?

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 15, 2021, 5:23pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/7 "2021-12-15T17:23:26Z")

</div>

No ,the API call ListLocations also returns the same error.  
I got this LY0HVM1W81FNS from Locations section in the portal.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 15, 2021, 5:29pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/8 "2021-12-15T17:29:28Z")

</div>

Okay, that definitely means that something isn’t configured correctly if you’re getting the not authorized error with ListLocations. What SDK are you using?

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 16, 2021, 1:11pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/9 "2021-12-16T13:11:46Z")

</div>

Hello,  
We are using SDK Package Version: 2.1.0  
Thanks,  
Jitendra

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 16, 2021, 5:19pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/10 "2021-12-16T17:19:06Z")

</div>

I can confirm that the `location_id` and the access token are correct for making calls to the sandbox environment. You’ll need to make sure that you’re also using the sandbox access token and you have the base path URL configured to sandbox.

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 16, 2021, 5:22pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/11 "2021-12-16T17:22:27Z")

</div>

This is the host url set in the library - [https://connect.squareup.com](https://connect.squareup.com)

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 16, 2021, 5:24pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/12 "2021-12-16T17:24:35Z")

</div>

That’s used for making production API calls. You’ll need to use `https://connect.squareupsandbox.com` to make API calls with your sandbox credentials. 🙂

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 16, 2021, 5:38pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/13 "2021-12-16T17:38:20Z")

</div>

okay, so I changed the host url in the library and I got this now -  
SquareConnect\ApiException Object  
(  
[responseBody:protected] =\> stdClass Object  
(  
[errors] =\> Array  
(  
[0] =\> stdClass Object  
(  
[category] =\> INVALID\_REQUEST\_ERROR  
[code] =\> GONE  
[detail] =\> The request could not be completed since access to the target resource is no longer available.  
)))

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 16, 2021, 6:04pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/14 "2021-12-16T18:04:23Z")

</div>

Is there a reason you’re calling the Transactions API? It’s deprecated. You should be using the [Payments API](https://developer.squareup.com/reference/square/payments-api).

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 17, 2021, 12:17pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/15 "2021-12-17T12:17:48Z")

</div>

Actually, we have integrated with Square Connect a few years ago and some of our clients are using that on live. So, we needed to test out a few things on that API.

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 17, 2021, 4:37pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/16 "2021-12-17T16:37:28Z")

</div>

Okay! So you’ll need to use a prior version of Square APIs. The most resent version that supports the Transactions API is 2021-09-15. The [Transactions API](https://developer.squareup.com/reference/square/transactions-api) are removed from Square API version 2021-10-20 and later. These endpoints will work if you are using Square API versions prior to 2021-10-20. However, these endpoints will eventually be retired from all Square versions. 🙂

---

<div class="post-metadata">

**Author:** ![Jitendra](https://avatars.discourse-cdn.com/v4/letter/j/74df32/32.png) [@Jitendra](https://developer.squareup.com/forums/u/Jitendra)\
**Post date:** [December 17, 2021, 4:44pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/17 "2021-12-17T16:44:34Z")

</div>

I see, is there a timeline to when we can expect the new changes as we would have to make changes in our integration as well?  
Thanks,  
Jitendra

---

<div class="post-metadata">

**Author:** ![Bryan-Square](https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/bryan-square/32/38_2.png) [@Bryan-Square](https://developer.squareup.com/forums/u/Bryan-Square)\
**Post date:** [December 17, 2021, 7:39pm UTC](https://developer.squareup.com/forums/t/sandbox-credentials/4527/18 "2021-12-17T19:39:10Z")

</div>

At this time the Transactions API retirement is TBD, but we highly recommend moving to the [Payments API](https://developer.squareup.com/docs/payments-refunds). 🙂
