addOrganizationUserRole()
, not methodThatCreatesUserARole()
.addOrganizationUserRole()
method requires three parameters: orgCode
, userId
, and roleId
. Make sure these are all valid and exist in your database.orgCode
, userId
, roleId
.createKindeManagementAPIClient()
to create the API client.addOrganizationUserRole()
method? This will help me understand the issue better and provide a more accurate solution. const response = await apiClient.organizationsApi.createOrganizationUserRole({ createOrganizationUserRoleRequest: { roleId: roleId }, orgCode: orgCode, userId: userId })
export interface CreateOrganizationUserRoleOperationRequest { orgCode: string; userId: string; createOrganizationUserRoleRequest: CreateOrganizationUserRoleRequest; }
export interface CreateOrganizationUserRoleRequest { /** * The role id. * @type {string} * @memberof CreateOrganizationUserRoleRequest */ roleId?: string; }
roleId
, orgCode
, and userId
are valid and exist in your database.roleId
is a string. If it's a number, you might need to convert it to a string before passing it to the method.roleId
is optional in your database. If it's not, you need to provide a valid roleId
.createKindeManagementAPIClient()
to create the API client.import { createKindeManagementAPIClient, getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server" // in React server-component: ... const apiClient = await createKindeManagementAPIClient();
const roles = await apiClient.rolesApi.getRoles() ...then get role id I want
/** * @returns access_token for accessing Kinde management API */ export const getKindeAccessToken = async (): Promise<any> => { const response = await fetch("https://riku.kinde.com/oauth2/token", { method: "POST", headers: { "content-type": "application/x-www-form-urlencoded", }, body: new URLSearchParams({ audience: "https://riku.kinde.com/api", grant_type: "client_credentials", client_id: process.env.KINDE_CLIENT_ID as string, client_secret: process.env.KINDE_CLIENT_SECRET as string, }) }) return response.json() } /** * @param roleId role to give to the Kinde user * @param userId id of the user to update * @param orgCode Kinde organization where the update happens in */ export const kindeAddRoleToUser = async (roleId: string, userId: string, orgCode: string): Promise<any> => { if(!roleId || !userId) { return } const { access_token: accessToken } = await getKindeAccessToken() console.log("using accessToken:", accessToken) const inputBody = JSON.stringify({ "role_id": roleId }) const headers = { "Content-Type":"application/json", "Accept":"application/json", "Authorization":`Bearer ${accessToken}` }; const response = await fetch(`https://riku.kinde.com/api/v1/organizations/${orgCode}/users/${userId}/roles`, { method: "POST", headers: headers, body: inputBody }) return response.json() }
import { KindeManagementAPIClient, CreateOrganizationUserRoleRequest } from '@kinde/management-api-client'; // Create an instance of the Kinde Management API client const apiClient = new KindeManagementAPIClient({ basePath: 'https://riku.kinde.com/api/v1', headers: { 'Authorization': `Bearer ${accessToken}` } }); // Create a request to add a role to a user const request: CreateOrganizationUserRoleRequest = { roleId: roleId }; // Call the method to add a role to a user const response = await apiClient.organizationsApi.createOrganizationUserRole({ orgCode: orgCode, userId: userId, createOrganizationUserRoleRequest: request });
accessToken
is the access token you obtained from getKindeAccessToken()
. @kinde/management-api-client
package to use the Kinde Management API client. You can install it using npm:npm install @kinde/management-api-client
We are going to have 2-3 paid tiers, eg 5$ 10$ and one moreIs it going to be like, e.g. $5/month, $10/month, etc...?
I'm trying to integrate Stripe to the app now and I'm doing it by making customers database table to our database, which only includes users whoWe will handle syncing your user data with Stripe in our Billing feature.
have subscribed to our service via stripe.