Sophia
Sophia
Explore posts from servers
KKinde
Created by Sophia on 5/21/2024 in #💻┃support
How to refresh tokens in a Next.js client component?
Hey @Oli - Kinde @Peter (Kinde) just checking in to see if you had any further thoughts?
14 replies
KKinde
Created by Sophia on 5/21/2024 in #💻┃support
How to refresh tokens in a Next.js client component?
Thank you @peteswah @Peter (Kinde) I've just tried this and the access_token and id_token don't seem to contain the updated data after refreshTokens() has been called, sorry! Happy to provide as much information as might be needed or even jump on a call if it's helpful, I'm not the most experienced with any of the technologies I'm using so it's very possible I've done something stupid, I'm just struggling to work out what it could be at this point as it does seem to just be this one function that's not behaving as expected
14 replies
KKinde
Created by Sophia on 5/21/2024 in #💻┃support
How to refresh tokens in a Next.js client component?
Sorry @Oli - Kinde I completely missed this response! Yep I'm using the NextJS SDK. If it helps, the repository link is here: https://github.com/phianova/KettleOn/tree/81-kinde-bug-and-responsiveness and the relevant branch is 81-kinde-bug-and-responsiveness
14 replies
KKinde
Created by Sophia on 5/21/2024 in #💻┃support
How to refresh tokens in a Next.js client component?
Ooh no I hadn't seen that, thank you @Oli - Kinde ! Having read it now, I think my tRPC setup is a little different to the structure of the example here, but so far I haven't had any issues with Kinde auth functioning in my app, this seems to be the first instance where any SDK methods aren't working as they should. For example, where I call getUser() from getKindeServerSession() in one of my tRPC API methods, the user data returns correctly. And the interactions I've set up with the Kinde API also work fine. refreshTokens() seems to be the only thing not working, as getPermissions() is returning the right sort of object but with the values as null, so it seems like there's just something I've misunderstood about the token management system maybe?
14 replies
KKinde
Created by Sophia on 5/21/2024 in #💻┃support
How to refresh tokens in a Next.js client component?
I've tried asking KindeAI here: https://discord.com/channels/1070212618549219328/1242517735389532331 it looks like everything is set up correctly? And to clarify I am receiving a success response from my tRPC call, the only problem is the response from getPermissions which is still null for both permissions and orgCode. I tried splitting it into two different tRPC calls and still got nothing so I think the problem lies with refreshTokens(). (I'm not sure if I'm breaking some rules by asking too many questions on here? I'm really sorry if so)
14 replies
KKinde
Created by hackerman on 5/20/2024 in #💻┃support
`getPermissions()` not returning latest data
Probably a silly question but I'm having the same issue...what is the best way to refresh the token after an update to permissions like this in the Next.js SDK?
6 replies
KKinde
Created by Sophia on 5/6/2024 in #💻┃support
Kinde sign-in screen register link means no new org
Hi @Peter (Kinde) , wondered if you (or the team) had any further thoughts on this? Thank you!
5 replies
KKinde
Created by Sophia on 5/6/2024 in #💻┃support
Kinde sign-in screen register link means no new org
Also, just generally how to build custom sign-up/sign-in screens with NextJS as the documentation only provides an indication of how a Login button might work - do I simply create a form? Does it need to be done via a request to the Kinde API?
5 replies
KKinde
Created by Sophia on 5/6/2024 in #💻┃support
Kinde sign-in screen register link means no new org
Thank you, I've already looked at most of these resources. I'll try and explain my issue more clearly. I'm using the is_create_org parameter with a <RegisterLink> to create new organisations whenever someone registers. However, the default Kinde sign-in screen (accessed via a <LoginLink>) provides an option to navigate to the default Kinde sign-up screen (see my screenshot). This means users are able to click that button and they are then registered WITHOUT creating a new organisation. I want to know if there's any way to bypass or prevent this, or if I'm simply unable to use the default sign-in/sign-up screens with the is_create_org parameter.
5 replies
TtRPC
Created by Sophia on 3/11/2024 in #❓-help
TRPC useQuery() in NextJS full stack with TypeScript
for further context my repo is here: https://github.com/phianova/KettleOn/tree/trpc-setup on the branch trpc-setup
3 replies
KKinde
Created by Sophia on 3/6/2024 in #💻┃support
Creating users via Kinde API
That's great, thank you!
11 replies
KKinde
Created by Sophia on 3/6/2024 in #💻┃support
Creating users via Kinde API
I tried asking Kinde AI too but not to much avail: https://discord.com/channels/1070212618549219328/1215295730151854140
11 replies
KKinde
Created by Sophia on 3/6/2024 in #💻┃support
Creating users via Kinde API
No description
11 replies
KKinde
Created by Sophia on 3/6/2024 in #💻┃support
Creating users via Kinde API
async function getAccessToken() { const url = 'https://kettleon.kinde.com/oauth2/token'; const clientId = process.env.KINDE_CLIENT_M2M_ID const clientSecret = process.env.KINDE_CLIENT_M2M_SECRET const options = { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: ${clientId}, client_secret: ${clientSecret}, audience: 'http://localhost:3000' }) }; const response = await fetch(url, options); const data = await response.json(); console.log(data) console.log("token", data.access_token) return data.access_token; } const addUser = async (e : any) => { e.preventDefault(); const accessToken = await getAccessToken() const inputBody = { "profile": { "given_name": ${e.target.given_name.value}, "family_name": ${e.target.family_name.value}, }, "organization_code": ${props.organisation}, "identities": [ { "type": "email", "details": { "email": ${e.target.email.value} } } ] }; const headers = { 'Content-Type':'application/json', 'Accept':'application/json', 'Authorization':Bearer ${accessToken}, 'Access-Control-Allow-Origin':'https://kettleon.kinde.com' }; await fetch('https://kettleon.kinde.com/api/v1/user', { method: 'POST', body: inputBody, headers: headers }) .then(function(res) { return res.json(); }).then(function(body) { console.log(body); }); }
11 replies