Device code creation, terminal sign in, Sandbox, Terminal API

Hello,

I am using the Sandbox Access Token to create a device code, I get a successful response, but when I use the code to sign on my Square terminal I get the error “Incorrect device code. Please check your device code and try again.” And If I use my Production Access Token to create a device code I get the following response with 401 response code:

"errors": [
    {
      "category": "AUTHENTICATION_ERROR",
      "code": "UNAUTHORIZED",
      "detail": "This request could not be authorized."
    }
  ]

:wave: Device codes created in sandbox won’t currently work with Terminal API. The Terminal API supports a collection of special device_id values you can use to simulate terminal checkouts without connecting to a physical Square Terminal. Successful Sandbox requests result in a payment generated in the Sandbox and shown in the Seller Dashboard for your test account. :slightly_smiling_face:

I get an error when I trying to create device code using the Production Access Token. The device code won’t be created.

What was the exact error message you got and what’s the application Id you’re using?

Application id : sq0idp-AGGJtNGBdBxvVibUedEpxQ
Error : {
“errors”: [
{
“category”: “AUTHENTICATION_ERROR”,
“code”: “UNAUTHORIZED”,
“detail”: “This request could not be authorized.”
}
]
}

I took a look at your API Logs for that application and see that all the requests to Devices API are in Sandbox not production. When calling production you’ll need to make sure you are using the correct access token and base path URL: https://connect.squareup.com/v2/devices/codes :slightly_smiling_face:

Thank you for the information Bryan!