Creating users via Kinde API
Hi there! Super new to Kinde and web development in general so apologies for my lack of knowledge in advance.
I'm trying to do something that I hope can be done via Kinde but I'm not 100% sure - I'd like for a logged in user with a specific role (ie a manager) to be able to add users to Kinde (within their organisation) via our site using the Kinde API.
Our app is full-stack NextJS using app routing with TypeScript, so I looked through the NextJS SDK documentation. I first got very stuck looking at the code snippets there as I couldn't find any documentation for how to use the API with createKindeManagementAPIClient especially trying to use the createUser method on the usersApi.
I then tried to just use fetch() using the code samples on the API docs themselves, but had issues with the access token. I've tried to obtain the access token via Postman which worked fine, so I think my setup on Kinde is correct, but for some reason the client authentication fails when I try to run it locally in my code.
Could this be because I'm using http://localhost:3000 for testing? I've tried setting the "audience" parameter to this URL to see if this resolves it.
I'll follow up with a comment containing the code I've currently got in my component where I'm trying to add users.
The env variables are the ones for my M2M application in Kinde. I've switched the API on for this application.
It's currently not getting to the addUser() function because the accessToken is coming back undefined because the client authentication isn't working.
Any ideas as to why this could be? Is it the domain or have I missed something else?
Thank you in advance
I'm trying to do something that I hope can be done via Kinde but I'm not 100% sure - I'd like for a logged in user with a specific role (ie a manager) to be able to add users to Kinde (within their organisation) via our site using the Kinde API.
Our app is full-stack NextJS using app routing with TypeScript, so I looked through the NextJS SDK documentation. I first got very stuck looking at the code snippets there as I couldn't find any documentation for how to use the API with createKindeManagementAPIClient especially trying to use the createUser method on the usersApi.
I then tried to just use fetch() using the code samples on the API docs themselves, but had issues with the access token. I've tried to obtain the access token via Postman which worked fine, so I think my setup on Kinde is correct, but for some reason the client authentication fails when I try to run it locally in my code.
Could this be because I'm using http://localhost:3000 for testing? I've tried setting the "audience" parameter to this URL to see if this resolves it.
I'll follow up with a comment containing the code I've currently got in my component where I'm trying to add users.
The env variables are the ones for my M2M application in Kinde. I've switched the API on for this application.
It's currently not getting to the addUser() function because the accessToken is coming back undefined because the client authentication isn't working.
Any ideas as to why this could be? Is it the domain or have I missed something else?
Thank you in advance