Posting the OAuth2 code to the accesstoken endpoint is returning a 404 page

I’m following the OAuth2 instructions and I was able to get the first part working which returns an auth_code.

When I try to do the next step (exchange the auth code for an access token) I am consistently getting a 404 html page response. I would have expected a JSON response from this endpoint (even for an error)

The endpoint in the documentation to get an access token is the following…
https://api.yextapis.com/oauth2/accesstoken

Is this the correct url? Is this also the url to use for a playground/sandbox account?

Is it ok that the redirect_uri is a localhost url? It worked for the first part and I’m using the exact same url for the accesstoken POST request (as specified in the documentation)

Is the client_secret supposed to use the OAuth2 Client Secret or the API Key? The documentation shows client_secret=<API_KEY> so it is a little unclear.

Thanks for any help on this.

Hi Tim,

Sorry about this. The endpoint in the documentation for the access token should be this:
https://api.yext.com/oauth2/accesstoken

Can you try that and let us know how it goes? We will get that updated ASAP.

Using just “localhost” should be fine. We use that in some of the apps we build when testing as well.

The client_secret should be the OAuth2 Client Secret. We will also update the documentation to make that clearer as well.

Let me know if you have any other questions! Thank you!
Dana

Thanks for the correct accesstoken url!

I tried it again and received this error message… “Missing required request params.”

I remembered seeing the following post when I was searching for more information about oauth.

In that post there is an image and in that image they show an additional request parameter.
grant_type=authorization_code

So I tried it again and included the “grant_type=authorization_code” parameter and it worked.
That parameter is currently not included in the documentation.

I was able to get this to work for my non-sandbox developer account, but it did not work for my “Playground/Sandbox” account.

Is there a different “accesstoken” endpoint that can be used for “Playground/Sandbox” accounts?

Thanks,
Tim

Hi Tim,

Thank you so much for following up! We will make sure that piece of the documentation gets updated as well.

I just checked with our engineers that also build apps in sandbox and the access token URL should be this: https://api-sandbox.yext.com/oauth2/api/accesstoken. Typically, we don’t recommend building and publishing apps in sandbox, which is why we don’t call that out in the documentation so we will leave that one out, but if you would like to test your changes and updates in sandbox, feel free.

Thank you!
Dana