K
Kindeβ€’3mo ago
wispyco

Email undefined for apple id registration on dashboard page

When a user registers and is redirected to the dashboard page after signing up I am using the following code to get the user information. import {getKindeServerSession} from "@kinde-oss/kinde-auth-nextjs/server"; export default async function Dashboard() { const {getUser} = getKindeServerSession(); const user = await getUser(); console.log(user); return (<div>Dashboard<pre>{JSON.stringify(user, null, 2)}</pre></div>); } In the console log on the server the email is undefined. Why may this be?
30 Replies
wispyco
wispycoOPβ€’3mo ago
this is for apple login
Claire_Kinde
Claire_Kindeβ€’3mo ago
Hi wispyco. So when a user sign up with apple you are not receiving their email address? And you are using Next.js Did this just start happening or has it never worked as you thought?
wispyco
wispycoOPβ€’3mo ago
I am using next, and i am developing in replit and it was the frist signup I tried
Claire_Kinde
Claire_Kindeβ€’3mo ago
K thanks. Also, have you asked the Kinde AI to see if it has an answer?
wispyco
wispycoOPβ€’3mo ago
GET /dashboard 200 in 22ms
{
id: 'kp_d5ec6ed4fe6d4bb1b657d6bc57488f96',
email: undefined,
family_name: 'Kitson',
given_name: 'Anders',
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
GET /dashboard 200 in 22ms
{
id: 'kp_d5ec6ed4fe6d4bb1b657d6bc57488f96',
email: undefined,
family_name: 'Kitson',
given_name: 'Anders',
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
I hadn't
Claire_Kinde
Claire_Kindeβ€’3mo ago
Give it a shot and let me know. #⚑⏐ask-kinde-ai
wispyco
wispycoOPβ€’3mo ago
It suggested this
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export default async function Dashboard() {
const { getUser, refreshTokens } = getKindeServerSession();

// Refresh tokens to get up-to-date Kinde data
await refreshTokens();

const user = await getUser();

console.log(user);

return (<div>Dashboard<pre>{JSON.stringify(user, null, 2)}</pre></div>);
}
import { getKindeServerSession } from "@kinde-oss/kinde-auth-nextjs/server";

export default async function Dashboard() {
const { getUser, refreshTokens } = getKindeServerSession();

// Refresh tokens to get up-to-date Kinde data
await refreshTokens();

const user = await getUser();

console.log(user);

return (<div>Dashboard<pre>{JSON.stringify(user, null, 2)}</pre></div>);
}
But it did not work?
Claire_Kinde
Claire_Kindeβ€’3mo ago
Did you also check that the email scope is included in the request? We cannot control anything on the Apple side. Are you able to sign up with a different apple account and see if the same thing happens? Otherwise, might need to wait til our dev who specialises in social connections comes back online.
wispyco
wispycoOPβ€’3mo ago
yeah I am prety sure I have the right permissions ok ill wait
No description
Claire_Kinde
Claire_Kindeβ€’3mo ago
I mean on the Apple side too when you configured your app.
Claire_Kinde
Claire_Kindeβ€’3mo ago
Kinde docs
Apple social sign in
Our developer tools provide everything you need to get started with Kinde.
wispyco
wispycoOPβ€’3mo ago
I have to configure a app on the apple side? Oh I never did that, thats probably why
Claire_Kinde
Claire_Kindeβ€’3mo ago
If you follow that doc, it should steer you right. Sometimes Apple changes config and button names etc on their side, but I think this was updated fairly recently. Let us know how you go πŸ™‚
wispyco
wispycoOPβ€’3mo ago
Will do So I setup all that apple developer stuff and now I am getting less data. This is the latest response from the AI The claim result you're seeing indicates that the email claim is not being populated, which could explain why you're not receiving the user's email in the profile data. This issue could be related to how the social login (in this case, Apple) is configured or how the claims are being processed. Here are a few steps you can take: Check your Kinde configuration to ensure that email scopes are requested during the authentication process. Verify that your Apple Sign-In configuration in Kinde is set up correctly and includes the necessary scopes. Try to refresh the tokens and then get the user data again. According to the NextJS App Router SDK documentation, you can use the refreshTokens() function before getting the user data : const { getUser, refreshTokens } = getKindeServerSession(); await refreshTokens(); const user = await getUser(); console.log(user); If the issue persists, you might need to check if the email is being returned in a different claim. You can use the getClaim method to check for other potential claims . Consider checking the access token directly. You can use the getAccessToken method provided by the SDK : const { getAccessToken } = getKindeServerSession(); const accessToken = await getAccessToken(); console.log(accessToken); This might give you more insight into what data is actually being returned from the authentication process. If after trying these steps you're still not receiving the email or other expected user data, it's possible that there's an issue with how the social login provider (Apple) is configured or how it's interacting with Kinde. In this case, you might need to reach out to Kinde support for further assistance with your specific configuration. This is the data I am getting back now
GET /dashboard 200 in 111ms
βœ“ Compiled /favicon.ico in 114ms (633 modules)
GET /favicon.ico 200 in 194ms
βœ“ Compiled in 406ms (927 modules)
{
id: 'kp_f78188d015d9493f89a71f802f60efec',
email: undefined,
family_name: undefined,
given_name: undefined,
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
GET /dashboard 200 in 111ms
βœ“ Compiled /favicon.ico in 114ms (633 modules)
GET /favicon.ico 200 in 194ms
βœ“ Compiled in 406ms (927 modules)
{
id: 'kp_f78188d015d9493f89a71f802f60efec',
email: undefined,
family_name: undefined,
given_name: undefined,
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
thanks
Claire_Kinde
Claire_Kindeβ€’3mo ago
So not fixed? I will pass this on to the team and see if they can help. Can you tell me your Kinde business and email please.
wispyco
wispycoOPβ€’3mo ago
Business is Lettabird and email is [email protected]
viv (kinde)
viv (kinde)β€’3mo ago
Hi @wispyco , are you able to check if Trust email addresses provided by this connection is ticked in your apple config? (in Kinde UI) Thanks!
wispyco
wispycoOPβ€’3mo ago
Hi it wasn't but I just ticked it now. I get this in my console
GET /api/auth/register? 307 in 1216ms
GET /api/auth/kinde_callback?code=redacted&scope=openid%20profile%20email%20offline&state=380436c0af59e45027ce1cfcbbf9 307 in 748ms
{
id: 'kp_f78188d015d9493f89a71f802f60efec',
email: undefined,
family_name: undefined,
given_name: undefined,
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
GET /dashboard 200 in 145ms
GET /api/auth/register? 307 in 1216ms
GET /api/auth/kinde_callback?code=redacted&scope=openid%20profile%20email%20offline&state=380436c0af59e45027ce1cfcbbf9 307 in 748ms
{
id: 'kp_f78188d015d9493f89a71f802f60efec',
email: undefined,
family_name: undefined,
given_name: undefined,
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
GET /dashboard 200 in 145ms
viv (kinde)
viv (kinde)β€’3mo ago
hi - apologies, I wasn't able to replicate this on mine. Are you able to check if you're receiving an email with the Kinde Apple app (ie remove your Apple credentials from the config) - just so we can narrow down where the issue may be coming from? thanks!
wispyco
wispycoOPβ€’3mo ago
Ok will do thanks with the kinde credentials i get
{
id: 'kp_d5ec6ed4fe6d4bb1b657d6bc57488f96',
email: undefined,
family_name: 'Kitson',
given_name: 'Anders',
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
{
id: 'kp_d5ec6ed4fe6d4bb1b657d6bc57488f96',
email: undefined,
family_name: 'Kitson',
given_name: 'Anders',
picture: 'https://gravatar.com/avatar/6c117141dc341f2b846b54e34468e66b24e4de275cd2a098a66c34b06666483c?d=blank&size=200',
username: undefined,
phone_number: undefined
}
Email claim: { name: 'email', value: null }
viv (kinde)
viv (kinde)β€’3mo ago
hmm are you able to invite [email protected] as a teammate to your business - i'll take a look ☺️ actually would you also be able to quickly check: 1. delete the user you created from Apple out of Kinde (as it was initially created without trust emails toggled on) 2. log in with apple (now with the trust emails on) 3. check id token
wispyco
wispycoOPβ€’3mo ago
will do oh where do I delete the user on the apple side somewhere I assume?
viv (kinde)
viv (kinde)β€’3mo ago
ahh sorry, you'll only need to delete it out of Kinde - from admin > users (delete the user you used to sign in w/apple)
wispyco
wispycoOPβ€’3mo ago
ok that worked, I wonder if the first user sign up captures the email with that toggle on. So do you think if I delete the user and user my credentials it may work? Also is there any advantage to using mine?
viv (kinde)
viv (kinde)β€’3mo ago
sweet good to hear - believe it's a bug, we should be collecting the emails as part of your profile (regardless of trusted or not) so I'll get that fixed up (thanks for flagging).
wispyco
wispycoOPβ€’3mo ago
My only question is, is there a difference between using my apple creds vs kindes? any benefit to using mine?
viv (kinde)
viv (kinde)β€’2mo ago
Hi, sorry are you able to clarify what you mean by Kinde's credentials? email vs single sign on w/Apple? thanks
wispyco
wispycoOPβ€’2mo ago
I meant like the apple client id and apple client secret. I actually have a second question for you. I am evaluating switching to expo, but your docs and options to create a expo app are confusing I see there is docs for the Expo and React Native SDK but there is no option to choose it in the client side app?
No description
No description
onderay
onderayβ€’2mo ago
@wispyco we recently launched a Expo SDK, let us know if they solves your needs. https://github.com/kinde-oss/expo
GitHub
GitHub - kinde-oss/expo: Library to integrate Kinde into an Expo pr...
Library to integrate Kinde into an Expo project. Contribute to kinde-oss/expo development by creating an account on GitHub.
jamisonsheppard
jamisonsheppardβ€’2mo ago
Edit: Nevermind, got it working! Is there a working example of kinde-oss/expo in use or as a starter kit? The expo-starter-kit I found in kinde-starter-kits is using kinde/js-utils and not the kinde-oss/expo library above.
Want results from more Discord servers?
Add your server