Welcome to the Kinde community

Updated 3 weeks ago

Kinde Management API Scopes in Body

I think there's a bug with the Kinde API when it comes to looking at scopes. Kinde's Management API doesn't work with the default way that Postman handles scopes for instance. If you supply the scopes in the body (default) Kinde will complain saying that the scopes are invalid. However, if you supply them in the headers, it will work.
S
5 comments
At a minimum I think the documentation needs to be updated, but Kinde's auth should probably be brought in line with industry standards for this. I'm guessing that given Postman's popular it's probably correct (or at least accepted) for scopes to be present in a body.
It looks like the same issue is there with the .NET SDK as it's also supplying scopes in the body. (Which wsa the original reason I was trying to use Postman). I'm going to see if I can circumvent Kinde's auth in some way without just forking the library to see if I can get it to work if I supply scope in the header.

Also, I'll log a GitHub issue but I also think the current approach that Kinde has towards exception management in that SDK could do with some improvement. Here's Kinde's code when authentication fails.

if (!response.IsSuccessStatusCode || string.IsNullOrEmpty(content)) { throw new ApplicationException("Invalid response from server: No token received"); }

There's two issues with this:
  • There is no way for a developer to understand why authentication failed unless they attach a debugger before the ApplicationException is thrown as the actual error is never reported, just a generic no token received. This is going to be problematic when troubleshooting issues outside of a developers local machine (e.g. production). If data sensitivity is a concern at least allow for a config value to allow for sensitive exceptions to be thrown (just like with the .NET OIDC libraries you can have a config setting to allow for PII data to be output)
  • Kinde is throwing ApplicationException. Both Microsoft and Jetbrains state in their base practices and code analytics do not throw ApplicationException (https://learn.microsoft.com/en-us/dotnet/standard/design-guidelines/using-standard-exception-types). The problem with throwing just the base Exception and ApplicationException types is that they are so general they give very little indication with what went wrong. I would suggest throwing a custom Kinde exception or using one of the .NET security or HTTP exception types.
Oh... it's confusing but I think I get it now... Yesterday when I was testing I was sure Kinde rejected me if I had a M2M access token without a read user scope when calling the users endpoint. Now it seems to be working, both through Postman and the .NET SDK. I guess for M2M you shouldn't supply scopes?
Add a reply
Sign up and join the conversation on Discord