K
Kinde5mo ago
moroshko

`await getUser()` doesn't return the first and last name

In my Next.js App Router application, in a page component, I get the user:
const { getUser } = getKindeServerSession();

const user = await getUser();

console.log(user);
const { getUser } = getKindeServerSession();

const user = await getUser();

console.log(user);
However, the first and last names are undefined:
{
family_name: undefined,
given_name: undefined,
picture: null,
email: 'my.email@gmail.com',
id: 'kp_e302a65c21bb45a7aaa378ccb9812345'
}
{
family_name: undefined,
given_name: undefined,
picture: null,
email: 'my.email@gmail.com',
id: 'kp_e302a65c21bb45a7aaa378ccb9812345'
}
I double checked on the Kinde User page that the user id and the email are the same and that the first and last names are set there. What am I missing?
4 Replies
moroshko
moroshko5mo ago
Oh, after logging out and logging in again, the first and last names appeared. I wonder if it's some sort of caching issue, or is it by design?! Steps to reproduce: 1. Sign up using a new email address. First and last names will be undefined, as expected. 2. Add first and last name on the user page in the Kinde UI. 3. First and last names are still returned as undefined. 4. Logout and login again. Now the first and last names are returned as expected.
Claire_Kinde
Claire_Kinde5mo ago
Thanks, we will look into this. Probably not until Monday. Hope it's not a show stopper for you at this stage.
Oli - Kinde
Oli - Kinde5mo ago
Hey @moroshko, This experience is as expected as between steps #2 and #3, the claims of the ID token (which include the first name and last name) are not refreshed. You can refresh the claims of the token using the getKindeServerSession().refreshTokens() method. Let me know if you have any other questions or queries.
moroshko
moroshko5mo ago
Makes sense, thanks!
Want results from more Discord servers?
Add your server