K
Kinde9mo ago
Mateuo

login front and backend with same token

Hi, I'm new using kinde and I'm surprised, it's great. My architecture is nuxt3 front and feathers for backend. Kind and front any surprise but with my backend (holds users, and manage my database) I tryed to send the same jwt token but I have issues. Has anyone an example of similar arquitecture for login on tbe front and reuse the token on the backend. Feathers has jwt and has the same secret.
1 Reply
Oli - Kinde
Oli - Kinde9mo ago
Hey @Mateuo, Thanks for reaching out. I'm glad to hear you're enjoying using Kinde. For integrating Kinde with a Nuxt3 front-end and a Feathers.js back-end, the key is to ensure that your Feathers.js back-end is set up to validate JWT tokens issued by Kinde. Since you're already using JWT in Feathers and have the same secret, you're on the right track. Here's a general approach to achieve this: 1. Passing the JWT Token: Once authenticated, your front-end application will receive a JWT token from Kinde. You'll need to send this token to your Feathers.js back-end with each request, typically as an Authorization header. For example:
fetch("https://your-feathers-api.com/endpoint", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

fetch("https://your-feathers-api.com/endpoint", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});

Make sure you replace ${accessToken} with the actual token received from Kinde. 2. Back-end (Feathers.js): On the Feathers.js side, you'll need to configure it to validate the JWT token against the same secret used by Kinde. Feathers.js uses the @feathersjs/authentication and @feathersjs/authentication-jwt packages for handling JWTs. You'll need to ensure that the JWT strategy is configured to use the same secret key that Kinde uses to sign the tokens. This might involve configuring the authentication service in Feathers.js to include a JWT strategy that validates the token's signature. 3. Validating Tokens: Since Kinde tokens are standard JWTs, you can use any JWT validation library if you prefer not to use the built-in Feathers.js authentication mechanisms. The key is to ensure that the secret (or public key, if using asymmetric keys) matches what Kinde uses. Unfortunately, I don't have a direct example of integrating Kinde with Feathers.js, but the general approach described above should guide you in the right direction. If you encounter specific issues with token validation on the Feathers.js side, I recommend checking the configuration of the JWT strategy in your Feathers.js application and ensuring that it's set up to use the correct secret or keys for token validation. For more detailed guidance on setting up authentication in Feathers.js, you can refer to the Feathers.js documentation on authentication: Feathers.js Authentication. If you need further assistance or have specific questions as you work through this integration, feel free to reach out!
Want results from more Discord servers?
Add your server