K
Kinde8mo ago
ooi cat

Reading Kinde user's discord id, if possible

Hey Is it possible to read Kinde user's discord id? Is it being stored?
No description
13 Replies
onderay
onderay8mo ago
You certainly can, you will just need to toggle this on in Applications > Tokens in your Kinde account
No description
ooi cat
ooi catOP8mo ago
@Andre @ Kinde
No description
ooi cat
ooi catOP8mo ago
Should I be able to see it when I get user by id from Kinde Management API? or maybe with next sdk getUser?
onderay
onderay8mo ago
Correct both of those methods work
ooi cat
ooi catOP8mo ago
For some reason, I could not get it to work. I might try again today This all started from not getting Patreon connected app to work. Well, it's not showing for me in the Connected Apps section. And also, thanks for the help so far Somehow, I'm still only getting properties, picture, email, and kinde user id, when I call getUser Do I have to manually attach additional data/scope when the oauth happens
ooi cat
ooi catOP8mo ago
I'm just getting user like this
No description
ooi cat
ooi catOP8mo ago
Down to hop on a quick call anytime to solve this just tag/dm/call
onderay
onderay8mo ago
Mmmm, let me check with our NextJS expert to come back with some additional direction
ooi cat
ooi catOP8mo ago
@Andre @ Kinde Might not need this anymore after the Patreon Connected App access grant for anyone else wondering, after you set additional claims to id token, at least for discord, they are put under ext_provider Next.js SDK (app router) example:
const { getIdToken } = getKindeServerSession();
const idToken = await getIdToken();
const externalProvider = idToken.ext_provider;
console.log(externalProvider)

/* Example output:
{
"claims": {
"is_confirmed": true,
"profile": {
"accent_color": 16711680,
"avatar": "https://example.com/avatar.jpg",
"banner_color": "#00FF00",
"discriminator": "1234",
"email": "[email protected]",
"flags": 128,
"global_name": "Example User",
"id": "123456789012345678",
"locale": "en-US",
"mfa_enabled": true,
"premium_type": 1,
"public_flags": 64,
"username": "exampleuser",
"verified": true
}
}
}
*/
const { getIdToken } = getKindeServerSession();
const idToken = await getIdToken();
const externalProvider = idToken.ext_provider;
console.log(externalProvider)

/* Example output:
{
"claims": {
"is_confirmed": true,
"profile": {
"accent_color": 16711680,
"avatar": "https://example.com/avatar.jpg",
"banner_color": "#00FF00",
"discriminator": "1234",
"email": "[email protected]",
"flags": 128,
"global_name": "Example User",
"id": "123456789012345678",
"locale": "en-US",
"mfa_enabled": true,
"premium_type": 1,
"public_flags": 64,
"username": "exampleuser",
"verified": true
}
}
}
*/
onderay
onderay8mo ago
So you have it all working now?
ooi cat
ooi catOP8mo ago
trying another method at the moment. Basically my site needs OAuth that gates login based on either patreon/disocrd role. Then it needs some role system to check out the users role and on pages check if the user can access or not. So regardless of the methods/tech I'd want something like this: - onSignIn: allow if patreon/discord active role - some way to read the role, either from token or from where the db auth user would be stored - invalidate session once subscription ends (easier for database user/session than for a JWT session) Right now I just have Discord OAuth used with JWT tokens that expire in two weeks. If only I get the refresh tokens working it's a pretty ok solution. But Next.js 14 and jwt refresh token has seemed harder than it should be Also the tokens get added the user role when they are initially issued. Not sure if this is good practice But this is off topic. Maybe I am just thinking about it all the wrong way...
onderay
onderay8mo ago
So the team had a quick think to give you some of our advice. Our thinking is the following flow which is similar to what you are thinking. 1. Use Custom sign/in with Discord SSO 2. Check the patreon connected app info via Kinde API 3. Get/update roles 4. Land the user in the product or somewhere else
ooi cat
ooi catOP8mo ago
Thanks!
Want results from more Discord servers?
Add your server