Is this the first time you are using the API or just the management API SDK?
It might be a good idea to just double check a few things:
Enable API AccessFirst, ensure you've enabled your application's access to the Kinde Management API. You can do this in Kinde by going to Settings > APIs > Kinde Management API and then toggling on your application under the Applications tab.
Authentication SetupThe error message suggests there might be an issue with your authentication credentials. Let's review the correct setup process:
Add a machine-to-machine application for API access and copy the necessary credentials.
Use these credentials to call the Kinde token endpoint. Here's an example in NodeJS:
const getAccessToken = async () => {
try {
const searchParams = {
grant_type: "client_credentials",
client_id: "<your_client_id>",
client_secret: "<your_secret_id>",
audience: "https://<your_subdomain>.kinde.com/api"
};
const res = await fetch("https://<your_subdomain>.kinde.com/oauth2/token", {
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
body: new URLSearchParams(searchParams)
});
const token = await res.json();
console.log({token});
} catch (err) {
console.error(err);
}
};
Use the obtained access token to call the Kinde management API:
const getUsers = async () => {
const accessToken = await getAccessToken();
const headers = {
'Accept': 'application/json',
'Authorization': `Bearer ${accessToken}`
};
try {
const res = await fetch('https://<your_subdomain>.kinde.com/api/v1/users', {
method: 'GET',
headers: headers
});
const data = await res.json();
console.log({data});
} catch (err) {
console.error(err);
}
TroubleshootingIf you're still encountering the "Invalid credentials" error after following these steps, double-check the following:
- Ensure you've correctly copied and pasted your client_id and client_secret.
- Verify that your application has the necessary permissions in the Kinde dashboard.
- Check that you're using the correct subdomain in your API calls.