Peteswah
Peteswah
KKinde
Created by Kenton on 8/27/2024 in #💻┃support
Kinde Management API - 400 Bad Request: malformed Host header
hey @Kenton - the purpose of refreshTokens is to sync up the the tokens stored in the cookies with Kinde data. So if Kinde data is updated via the api, data will be changed on Kinde, but it wont be reflected in the tokens (in your app) unless you refreshTokens. Hope that made sense!
15 replies
KKinde
Created by Kenton on 8/27/2024 in #💻┃support
Kinde Management API - 400 Bad Request: malformed Host header
Although you may want to have it inside the trycatch 😄
15 replies
KKinde
Created by Kenton on 8/27/2024 in #💻┃support
Kinde Management API - 400 Bad Request: malformed Host header
Something like:
import {NextRequest, NextResponse} from "next/server";
import {Organizations, init} from "@kinde/management-api-js";

export async function POST(req: NextRequest) {
const {refreshTokens} = getKindeServerSession()
try {
init();

const orgResponse = await Organizations.createOrganization({
requestBody: {
name: "test-org",
handle: "test-org",
},
});

const orgCode = orgResponse.organization?.code;
const userId = "hard_coded_user_id"
if (orgCode && userId) {
const response = await Organizations.addOrganizationUsers({
orgCode: orgCode,
requestBody: {
users: [{ id: userId }],
},
});
console.log("User added successfully:", response);
} else {
console.error("Invalid orgCode or user ID");
}
} catch (error) {
console.error("Error creating organization or adding user:", error);
}
await refreshTokens();
return NextResponse.json({});
}
import {NextRequest, NextResponse} from "next/server";
import {Organizations, init} from "@kinde/management-api-js";

export async function POST(req: NextRequest) {
const {refreshTokens} = getKindeServerSession()
try {
init();

const orgResponse = await Organizations.createOrganization({
requestBody: {
name: "test-org",
handle: "test-org",
},
});

const orgCode = orgResponse.organization?.code;
const userId = "hard_coded_user_id"
if (orgCode && userId) {
const response = await Organizations.addOrganizationUsers({
orgCode: orgCode,
requestBody: {
users: [{ id: userId }],
},
});
console.log("User added successfully:", response);
} else {
console.error("Invalid orgCode or user ID");
}
} catch (error) {
console.error("Error creating organization or adding user:", error);
}
await refreshTokens();
return NextResponse.json({});
}
15 replies
KKinde
Created by Kenton on 8/27/2024 in #💻┃support
Kinde Management API - 400 Bad Request: malformed Host header
yup! I think what we want here is to call refreshTokens() from getKindeServerSession before returning the NextResponse
15 replies
KKinde
Created by Yvens on 4/22/2024 in #💻┃support
What would be the most secure way to create invitation link for users to join an organizations ?
^ That is a great idea
5 replies
KKinde
Created by dillorscroft on 8/13/2024 in #💻┃support
Custom Properties
The getUser function will return a user with the custom properties as long as they are in the token. You will have to define which custom properties you have to get the TS autocomplete to work. So const user = await getUser<{myCustomProp: string}>().
{
id: ...,
first_name: ...,
...,
properties: {
...,
myCustomProp: "hello world"
}
}
{
id: ...,
first_name: ...,
...,
properties: {
...,
myCustomProp: "hello world"
}
}
13 replies
KKinde
Created by dillorscroft on 8/13/2024 in #💻┃support
Custom Properties
Hey guys, there is a PR waiting to get merged with the changes
13 replies
KKinde
Created by DavidF9265 on 8/17/2024 in #💻┃support
Post logout url in NextjsSDK not redirecting
Also if I could get confirmation that the allowed logout redirect URLs are for the correct Application, that would be helpful info to help us debug
19 replies
KKinde
Created by DavidF9265 on 8/17/2024 in #💻┃support
Post logout url in NextjsSDK not redirecting
I believe setting KINDE_POST_LOGOUT_URL in your .env should be enough to get it to work, and setting in the LogoutLink is not necessary
19 replies
KKinde
Created by DavidF9265 on 8/17/2024 in #💻┃support
Post logout url in NextjsSDK not redirecting
No description
19 replies
KKinde
Created by DavidF9265 on 8/17/2024 in #💻┃support
Post logout url in NextjsSDK not redirecting
Hey @DavidF9265 sorry you're experiencing this, I managed to recreate the issue you were having, but it was quite flaky. When you test it again, would you be able to check and maybe send screenshots of the post_login_redirect_url set in your cookies and the logout requests from the network tab
19 replies
KKinde
Created by erich_fromm on 8/7/2024 in #💻┃support
refreshTokens when expired
But definielty something we want to address soon and optimise
10 replies
KKinde
Created by erich_fromm on 8/7/2024 in #💻┃support
refreshTokens when expired
I'll just reply here - initially I had a check for the token expiry before calling refreshTokens like you had suggested but I was running into issues with that. I will need to take a deeper look into it next week. I think there is some condition in the TS SDK (which the Remix SDK is built on top of) that may be the cause of the weird behaviour. That's why it has been released in its current state
10 replies
KKinde
Created by erich_fromm on 8/7/2024 in #💻┃support
refreshTokens when expired
Thanks @erich_fromm
10 replies
KKinde
Created by erich_fromm on 8/7/2024 in #💻┃support
refreshTokens when expired
Hey @erich_fromm, I made a new release of the remix sdk which fixes this issue 😄
10 replies
KKinde
Created by dillorscroft on 8/13/2024 in #💻┃support
Custom Properties
In the meantime I think you can use the getClaimValue / getClaim helpers
13 replies
KKinde
Created by dillorscroft on 8/13/2024 in #💻┃support
Custom Properties
Hey @dillorscroft thanks for bringing this up - probably not the best experience here. I'll see do some investigation and see if there is a way to grab the custom properties with the existing helper functions. If that's not possible I'll make it possible.
13 replies
KKinde
Created by C on 7/13/2024 in #💻┃support
phone sign in, custom has changed
This format worked for me: login_hint: "phone:+61 23412341243124",
31 replies
KKinde
Created by summer_teng on 7/18/2024 in #💻┃support
LogoutLink is not redirecting to my desire URL
Hey @summer_teng sorry you're having this issue 😦 my hunch is using permanentRedirect instead of redirect my fix the problem
11 replies
KKinde
Created by C on 7/13/2024 in #💻┃support
phone sign in, custom has changed
Hey @C, sorry about that Daniel went on leave would you be able to send me the loginURL?
31 replies