Unable to obtain OAuth access token using Sandbox API Explorer

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 : [email protected]

  2. Application : siraasganpoc

  3. List Locations API returns the location

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”: “[email protected]”,
“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”: “[email protected]”,
“type”: “PHYSICAL”,
“business_hours”: {},
“mcc”: “7299”
}
]
}

  1. Create Mobile Authorization Code returns Authorization Code

curl 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
-X POST
-H ‘Square-Version: 2022-11-16’
-H ‘Content-Type: application/json’
-d ‘{
“grant_type”: “authorization_code”,
“redirect_uri”: “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!!

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 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. :slightly_smiling_face:

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

Regards
Siva Manickam