K
Kinde4mo ago
Faris

Kinde Integration

Hi, I am new here and I would like to integrate Kinde for my app but I am not really sure which docs should I refer for my requirement. I am using Angular for my Frontend as well as Express NodeJS as my backend API.
9 Replies
Oli - Kinde
Oli - Kinde4mo ago
Hey @Faris, Welcome to Kinde! It's great to hear you're considering integrating Kinde for your app. Based on your requirements, you'll be looking at a combination of resources for both your Angular frontend and your Express NodeJS backend. For your Angular frontend, while there isn't a specific Angular SDK mentioned in the resources provided, you can use the JavaScript SDK as a starting point. Angular applications can integrate with JavaScript libraries, so the JavaScript SDK documentation will be relevant for your frontend development. You can find more information and get started with the JavaScript SDK here: JavaScript SDK Documentation. For your Express NodeJS backend, you're in luck! There is a specific SDK for ExpressJS. You can start by adding the Kinde ExpressJS SDK as a dependency to your project and follow the integration instructions. The documentation for the ExpressJS SDK, including how to set it up and integrate it with your app, is available here: ExpressJS SDK Documentation. To summarize, you'll be looking at: - Frontend (Angular): Use the JavaScript SDK as there isn't a specific Angular SDK. The JavaScript SDK should work well with Angular applications. - Backend (Express NodeJS): Use the ExpressJS SDK designed specifically for Express applications. Remember, if you have any questions or need further assistance, let me know.
Faris
Faris4mo ago
thank you for the response. Does that means I need to create two seperate application on my kinde dashboard?
Oli - Kinde
Oli - Kinde4mo ago
It depends really on whether you want to do server-side authentication or client-side authentication. For example, if you want to do server-side authentication, you only need to have a look at the expressJS SDK Let me know if you have any other questions
Faris
Faris4mo ago
sorry if i have many questions but trying to understand here. currently im using my api and creating my own authentication but maintaining it is not feasible which is why i decided to try and migrate over to Kinde. So if i would like to authenticate everything from server side i only look at the expressJS SDK?
Oli - Kinde
Oli - Kinde4mo ago
No need to apologise @Faris. Feel free to ask as many questions as you like.
So if i would like to authenticate everything from server side i only look at the expressJS SDK?
Correct, you only need to use the expressJS SDK Let me know if you have any other questions.
Faris
Faris4mo ago
Okay thanks for the info so on backend ill call kindeClient.login right? Ill create an endpoint? Let me try and update if its successful thanks a lot
Oli - Kinde
Oli - Kinde4mo ago
Hey @Faris, in the ExpressJS SDK, we have made it easier for you where your backend can call /login to login or /register to register - see the ExpressJS doc section on this here. If you would rather call an endpoint like kindeClient.login(), you can do this in the NodeJS SDK - see the NodeJS section on this here. The ExpressJS wraps around the NodeJS SDK, but we have made things easier for your in the ExpressJS SDK. I hope this helps. Let me know if you have anymore questions.
Kinde Docs
NodeJS SDK - Developer tools - Help center
Our developer tools provide everything you need to get started with Kinde.
Kinde Docs
ExpressJS SDK - Developer tools - Help center
Our developer tools provide everything you need to get started with Kinde.
Faris
Faris4mo ago
I got it to work with this package instead https://kinde.com/docs/developer-tools/typescript-sdk/. im just wondering would it be possible if i get the access token and verify from my node backend? is there a function for that?
Kinde Docs
TypeScript SDK - Developer tools - Help center
Our developer tools provide everything you need to get started with Kinde.
Oli - Kinde
Oli - Kinde4mo ago
Hey @Faris, Great to hear you had success with our TypeScript SDK. Yes, I can guide you on how to verify the access token using the NodeJS SDK and ExpressJS SDK provided by Kinde. For the NodeJS SDK, you can verify the access token by setting it in the headers request and then making API calls. Here's a snippet from the documentation that illustrates how to do this:
const {KindeClient, ApiClient, OAuthApi} = require("@kinde-oss/kinde-nodejs-sdk");

// Get Access Token
const access_token = await kindeClient.getToken(req);

const apiClient = new ApiClient("https://your_kinde_domain.com");

// Set access token in the headers request
apiClient.authentications.kindeBearerAuth.accessToken = access_token;

const apiInstance = new OAuthApi(apiClient);
apiInstance.getUserProfileV2((error, data) => {
if (error) {
console.error(error);
} else {
console.log("API called successfully. Returned data: " + JSON.stringify(data, null, 2));
}
});
const {KindeClient, ApiClient, OAuthApi} = require("@kinde-oss/kinde-nodejs-sdk");

// Get Access Token
const access_token = await kindeClient.getToken(req);

const apiClient = new ApiClient("https://your_kinde_domain.com");

// Set access token in the headers request
apiClient.authentications.kindeBearerAuth.accessToken = access_token;

const apiInstance = new OAuthApi(apiClient);
apiInstance.getUserProfileV2((error, data) => {
if (error) {
console.error(error);
} else {
console.log("API called successfully. Returned data: " + JSON.stringify(data, null, 2));
}
});
This example demonstrates how to obtain an access token and use it to make authenticated requests to the Kinde API. You can find more details in the NodeJS SDK documentation. For the ExpressJS SDK, the documentation provides a way to verify JWTs signed by Kinde, which can be used as a layer to protect API endpoints. Here's how you can initialize the library for JWT verification:
const express = require("express");
const {jwtVerify} = require("@kinde-oss/kinde-node-express");

const app = express();

const verifier = jwtVerify("https://<your_kinde_subdomain>.kinde.com");
const express = require("express");
const {jwtVerify} = require("@kinde-oss/kinde-node-express");

const app = express();

const verifier = jwtVerify("https://<your_kinde_subdomain>.kinde.com");
This snippet shows how to set up JWT verification in an Express application. The jwtVerify function is part of the ExpressJS SDK, and it helps in verifying JWTs for authenticated requests. More information can be found in the ExpressJS SDK documentation.