Closed noelalfaro closed 4 months ago
Hey @noelalfaro thanks for raising this - I'll put in a fix to add the username to the User object.
In the meantime you can get around this by doing
const { getIdToken } = getKindeServerSession();
const idToken = await getIdToken();
console.log(idToken.preferred_username)
Trying out that workaround right now and the KindeIdToken
type does not have a preferred_username
property but when I console log the entire idToken object returned from await getIdToken()
the property does exist.
Hey @noelalfaro we've added the username property to the KindeUser
object now
type KindeUser = {
id: string;
email: string | null;
given_name: string | null;
family_name: string | null;
picture: string | null;
username?: string | null;
phone_number?: string | null;
properties?: {
usr_city?: string;
usr_industry?: string;
usr_job_title?: string;
usr_middle_name?: string;
usr_postcode?: string;
usr_salutation?: string;
usr_state_region?: string;
usr_street_address?: string;
usr_street_address_2?: string;
};
};
Prerequisites
Describe the issue
I'm attempting to retrieve the username property for users that have usernames set. However, the getUser method from the getKindeServerSession function only returns an object with the following properties:
The username property is missing from the response despite the fact that users do have usernames set.
Steps to Reproduce
Import the getKindeServerSession function from @kinde-oss/kinde-auth-nextjs/server.
Call the getUser method.
Observe the response object.
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";
export default async function Home() {
const { getUser } = getKindeServerSession();
const user = await getUser();
console.log(user);
return (
);
}