OAuth "obtain token" returns "Not Found"

When I go to obtain a token for a user at this endpiont: https://developer.squareup.com/reference/square/oauth-api/obtain-token, It just sends an error response “Not Found”.

I have double/triple checked that the client_id and client_secret (Application ID, Application Secret) are correct. The grant_type is “authorization_code” and the code is the code that is sent in the url after authorization. The user authorizes and all of the data is correct, but I constantly get “Not Found”.

This was working for me previously, but has stopped working all of a sudden. How do I fix this?

Just to double-check, was the code generated in sandbox or production? Are you using the correct credentials for ObtainToken (production/sandbox) according to how the code was generated? If so, can you provide your application id and I’ll take a look at our logs?

The code was generated in sandbox, and yes I am getting a sandbox code in the URL as well as using my sandbox credentials. App ID: sandbox-sq0idb-Zq3N9AtN2dfFrTxrFd1sJg

The last time I see ObtainToken called with that application id was August 14th, and it was successful. I do not see a “Not Found” error at all with that sandbox app id. Are you still receiving this error?

Ya, I am still getting the error. I tried removing the app from the seller account that I am logged in with. After I do the token request, the app appears in the seller’s list of apps. However, it shows: “Sandbox for {production app ID}” Not sure if that should be the sandbox app ID or not or if it indicates anything.

I have checked everything about a 100 times each to make sure that everything is sandbox and I haven’t accidentally added any production data for the app.

Just to check, the URL should be: “https://connect.squareupsandbox.com/oauth2/token”, correct?

That is correct. I see from 8/26 that you did one ObtainToken call with that application id, and our logs indicate it was successful (about 9 hours ago, when you posted); it returned an access token. I still do not see any errors for that application id.

Just to make sure we’re looking at the same application: if you call ListMerchants (GET on /v2/merchants/), what is the “id” that is returned?

I got it working now, though I don’t really understand how. Apparently the URL was incorrect. I had it using https, then I changed it to http just to check, then changed it back and it started working again. Not sure how I had the address wrong in the first place, but it seems to be working now.

Thanks again for your help.

1 Like