502 badgateway on m2m token endpoint

When I try to POST with postman to the token endpoint https://business.kinde.com/oauth2/token I get a 502 badgateway It doesn't matter whether I try the correct client_id or just random chars. I would expect to get 401 or 403 if the credentials are wrong. Tried with this body and Content-Type: application/json
{
"client_id": "XXX",
"client_secret": "XXX",
"grant_type": "client_credentials",
"audience": "http://api.example.com/api"
}
{
"client_id": "XXX",
"client_secret": "XXX",
"grant_type": "client_credentials",
"audience": "http://api.example.com/api"
}
I do not use scope as I'm currently on the free tier, only testing out kinde.
3 Replies
Ages
Ages4d ago
Hi @drachmann_40131, The issue appears to be with the Content-Type header. When making a token request to Kinde's token endpoint, you need to use application/x-www-form-urlencoded instead of application/json. Here's the correct way to structure your request: 1) Set the Content-Type header to: content-type: application/x-www-form-urlencoded 2) Include the required parameters in the body as form data:
client_id=<your_m2m_client_id>
client_secret=<your_m2m_client_secret>
audience=https://<your_subdomain>.kinde.com/api
grant_type=client_credentials
client_id=<your_m2m_client_id>
client_secret=<your_m2m_client_secret>
audience=https://<your_subdomain>.kinde.com/api
grant_type=client_credentials
If using Postman: - Select "Body" - Choose "x-www-form-urlencoded" - Add the key-value pairs as shown above With the correct Content-Type and body format, you should receive proper authentication responses (401/403) for invalid credentials rather than a 502 Bad Gateway error. Let me know if you need any further clarification!
Drachmann
DrachmannOP3d ago
Hi. It works. Thank you very much. 👍 I don't know whether you are working at Kinde, but maybe you could consider updating this doc: https://docs.kinde.com/developer-tools/your-apis/access-to-your-api/#provide-access-to-third-parties it lead me to belive that json was the correct format.
Kinde docs
Give others access to your API
Our developer tools provide everything you need to get started with Kinde.
Ages
Ages3d ago
Hi, You're very welcome! 😊 I'm glad it worked for you. I really appreciate your feedback on the documentation and will pass it along to our team for review. Your input is valuable in improving the experience for everyone! Let me know if there's anything else I can help with.

Did you find this page helpful?