# Unable to obtain OAuth access token using Sandbox API Explorer

**URL:** <https://developer.squareup.com/forums/t/unable-to-obtain-oauth-access-token-using-sandbox-api-explorer/7754>\
**Category:** Questions\
**Tags:** sandbox, oauth-api\
**Created:** [November 28, 2022, 4:29pm UTC](https://developer.squareup.com/forums/t/unable-to-obtain-oauth-access-token-using-sandbox-api-explorer/7754 "2022-11-28T16:29:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivamanickam](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sivamanickam](https://developer.squareup.com/forums/u/sivamanickam)\
**Post date:** [November 28, 2022, 4:29pm UTC](https://developer.squareup.com/forums/t/unable-to-obtain-oauth-access-token-using-sandbox-api-explorer/7754/1 "2022-11-28T16:29:33Z")

</div>

I’m unable to obtain oAuth Access Token. The API Obtain token returns **“Authorization code not found for app [sandbox-sq0idb-Id892Gi\_zNR0c8naV275ew]”**

Details below:

1. Account : [sivahere2003@gmail.com](mailto:sivahere2003@gmail.com)

2. Application : siraasganpoc

3. List Locations API returns the location

```auto
curl https://connect.squareupsandbox.com/v2/locations \
  -H 'Square-Version: 2022-11-16' \
  -H 'Authorization: Bearer ***' \
  -H 'Content-Type: application/json'

```

Response:  
{  
“locations”: [  
{  
“id”: “L8JA7YYVPSKWH”,  
“name”: “[sivahere2003@gmail.com](mailto:sivahere2003@gmail.com)”,  
“address”: {  
“address\_line\_1”: “1600 Pennsylvania Ave NW”,  
“locality”: “Washington”,  
“administrative\_district\_level\_1”: “DC”,  
“postal\_code”: “20500”,  
“country”: “US”  
},  
“timezone”: “UTC”,  
“capabilities”: [  
“CREDIT\_CARD\_PROCESSING”,  
“AUTOMATIC\_TRANSFERS”  
],  
“status”: “ACTIVE”,  
“created\_at”: “2022-11-24T03:36:51.845Z”,  
“merchant\_id”: “MLCF4CMBXQ0QF”,  
“country”: “US”,  
“language\_code”: “en-US”,  
“currency”: “USD”,  
“business\_name”: “[sivahere2003@gmail.com](mailto:sivahere2003@gmail.com)”,  
“type”: “PHYSICAL”,  
“business\_hours”: {},  
“mcc”: “7299”  
}  
]  
}

1. Create Mobile Authorization Code returns Authorization Code

curl [https://connect.squareupsandbox.com/mobile/authorization-code](https://connect.squareupsandbox.com/mobile/authorization-code)   
-X POST   
-H ‘Square-Version: 2022-11-16’   
-H ‘Authorization: Bearer \*\*\*’   
-H ‘Content-Type: application/json’   
-d ‘{  
“location\_id”: “L8JA7YYVPSKWH”  
}’

Response:  
{  
“authorization\_code”: “sandbox-sq0acb-V0eOUPT331jgLScVwEiL3Zq3VoI6PuKunYkJCUmP\_iI”,  
“expires\_at”: “2022-11-26T00:30:13Z”  
}

1. Obtain Token API Returns below error

curl [https://connect.squareupsandbox.com/oauth2/token](https://connect.squareupsandbox.com/oauth2/token)   
-X POST   
-H ‘Square-Version: 2022-11-16’   
-H ‘Content-Type: application/json’   
-d ‘{  
“grant\_type”: “authorization\_code”,  
“redirect\_uri”: “[http://localhost:5150/](http://localhost:5150/)”,  
“client\_id”: “sandbox-sq0idb-Id892Gi\_zNR0c8naV275ew”,  
“client\_secret”: “\*\*\*”,  
“code”: “sandbox-sq0acb-V0eOUPT331jgLScVwEiL3Zq3VoI6PuKunYkJCUmP\_iI”  
}’

Response:  
{  
“errors”: [  
{  
“category”: “AUTHENTICATION\_ERROR”,  
“code”: “UNAUTHORIZED”,  
“detail”: “Authorization code not found for app [sandbox-sq0idb-Id892Gi\_zNR0c8naV275ew]”  
}  
]  
}

Appreciate any help

Thanks!!

---

<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:** [November 28, 2022, 6:33pm UTC](https://developer.squareup.com/forums/t/unable-to-obtain-oauth-access-token-using-sandbox-api-explorer/7754/2 "2022-11-28T18:33:15Z")

</div>

Is this for a web application or a mobile application? With OAuth the `code` that’s passed in the `Obtain_token` request is returned in the redirect URL from the [Authorize](https://developer.squareup.com/reference/square/oauth-api/authorize) call. It returns an `AuthorizeResponse` that is sent to the redirect URL and includes a state string and an authorization code. The code is used in the `ObtainToken` call to obtain an access token and a refresh token that the developer uses to manage resources on behalf of the seller. 🙂

---

<div class="post-metadata">

**Author:** ![sivamanickam](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@sivamanickam](https://developer.squareup.com/forums/u/sivamanickam)\
**Post date:** [December 2, 2022, 12:53pm UTC](https://developer.squareup.com/forums/t/unable-to-obtain-oauth-access-token-using-sandbox-api-explorer/7754/3 "2022-12-02T12:53:12Z")

</div>

Thanks for your response. This is for both web and mobile application.

Regards  
Siva Manickam
