K
Kinde4mo ago
Bigail

Hey, i want to make a data stored per accounts using kinde typescript, how to do it?

I need help, i am going to store a data that saves per user using kinde authentication. can anyone make this happen?
22 Replies
Oli - Kinde
Oli - Kinde4mo ago
Hey @Bigail, You can store custom data (and pass that data to your app in the token) with properties. I would recommend having a read of the following guide: https://kinde.com/docs/properties/ If this won't solve your use-case, please let me know. I can then help you further.
Kinde Docs
About properties - Properties - Help center
Our developer tools provide everything you need to get started with Kinde.
Bigail
Bigail4mo ago
i still don't understand, i basically have a website that store a data in numbers and i want them to be saved per accounts
Bigail
Bigail4mo ago
basically i want to store this data per accounts
No description
Bigail
Bigail4mo ago
can you give me step by step on how to make it i also used the js starter kit to make the kinde authentication so i have 0 experiences in customizing kinde typescripts
Oli - Kinde
Oli - Kinde4mo ago
No worries @Bigail, I can help you out. I can guide you through a general approach of using Properties for your use-case that applies to JavaScript. The process involves creating custom properties in Kinde and then updating these properties for each user based on their macros and exercise data. Step-by-Step Guide: 1. Create Custom Properties in Kinde: - Log into your Kinde dashboard. - Navigate to the section where you can manage user properties. This might be under a "Users" or "Settings" menu. - Create custom properties for each data point you want to store. Based on your requirements, you would create properties for: - Carbohydrates - Fat - Protein - Exercises - Total Reps - Calories - Each of these properties should be set to accept number values. 2. Update Custom Properties for a User: - After creating the custom properties, you'll need to update these properties with the actual data for each user. This typically involves making API calls to Kinde to update a user's properties based on their activities or inputs in your application. - Since you're using the JavaScript starter kit, you'll be working with client-side code. However, updating user properties might require server-side logic due to the need for secure authentication with the Kinde API. 3. Securely Handling Updates: - To securely update user properties, you might need to create an API endpoint in your application that handles the update logic. This endpoint would receive data from the client side, authenticate with Kinde using server-side credentials, and then make the appropriate API calls to update the user's custom properties. - The specific API calls would depend on Kinde's API documentation for updating user properties. Look for sections related to managing user data or properties in the Kinde API documentation. 4. Fetching and Displaying Updated Properties: - Once the properties are updated, you can fetch these properties for a user to display their macros and exercise data in your application. This might involve calling a Kinde API endpoint to retrieve a user's properties and then displaying this data in your application's UI. Example Code Snippet: Since you're starting with the JavaScript SDK, here's a hypothetical example of how you might structure the client-side request to your API endpoint for updating user data (note that this is a simplified example):
// Example function to send macros and exercise data to your API endpoint
function updateUserData(macros, exercise) {
fetch('/api/updateUserData', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ macros, exercise }),
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch((error) => console.error('Error:', error));
}
// Example function to send macros and exercise data to your API endpoint
function updateUserData(macros, exercise) {
fetch('/api/updateUserData', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ macros, exercise }),
})
.then(response => response.json())
.then(data => console.log('Success:', data))
.catch((error) => console.error('Error:', error));
}
This function would send the macros and exercise data to an API endpoint (/api/updateUserData) in your application, which would then handle the server-side logic to authenticate with Kinde and update the user's properties. Important Considerations: - Ensure that any interaction with the Kinde API that requires authentication is handled securely and server-side. - Always validate and sanitize user inputs to prevent security vulnerabilities. Let me know if you have any further questions.
Bigail
Bigail4mo ago
can we delete the properties we created?
Oli - Kinde
Oli - Kinde4mo ago
You sure can
Bigail
Bigail4mo ago
i cannot delete this one i made, it said it's a property of kinde
No description
Bigail
Bigail4mo ago
also how do you make the API @Oli - Kinde hello?
Oli - Kinde
Oli - Kinde4mo ago
Hey @Bigail, Sorry for the delayed response. This is a bug, I have raised this with my team. I would suggest creating a new property for the meantime. Here are API calls that may be of interest to you: API docs are updated with Properties endpoints: Property config - https://kinde.com/api/docs/#kinde-management-api-properties - https://kinde.com/api/docs/#kinde-management-api-property-categories Set property values - User: https://kinde.com/api/docs/#update-property-values-2 - Organization: https://kinde.com/api/docs/#update-property-values Please let me know if you have any questions.
Bigail
Bigail4mo ago
thank you, i'll let you know later if i need more help
Oli - Kinde
Oli - Kinde4mo ago
No worries. Please don't hesitate to reach out and apologies again for the delayed response
Bigail
Bigail4mo ago
Not a problem Mr.Oli :Excuse_Me: i still don't understand @Oli - Kinde , maybe can you provide a step by step on how to setup the API in typescript
Oli - Kinde
Oli - Kinde4mo ago
Hi @Bigail, I will have to speak to my TypeScript SDK teammate on Monday on how to do this. I will get back to you then.
Bigail
Bigail4mo ago
Okay, I'll wait!
Oli - Kinde
Oli - Kinde4mo ago
Hey @Bigail, Just confirming. Do you want a setp-by-step guide on how to call the Properties API endpoints in your typescript application? If so, are you able to explain a bit more about your setup? What is languages/frameworks are you using in your frontend backend? Are you using a Kinde SDK? If so what SDK?
Bigail
Bigail4mo ago
yess i want a step by step guide, i use the kinde javascript sdk starter guide that gives you typescript as default
Oli - Kinde
Oli - Kinde4mo ago
Hey @Bigail, You will need a backend server to call the Kinde Management API endpoints. Do you have a backend server? If so, what language/framework is used?
Bigail
Bigail4mo ago
i don't think i have a backend server
Oli - Kinde
Oli - Kinde4mo ago
You would need a backend server to call our API endpoints. It is not secure to store an access token, to access the Kinde Management API, in your front-end server (in the browser)
Bigail
Bigail4mo ago
how do i make one
Oli - Kinde
Oli - Kinde4mo ago
Hey @Bigail, There are many ways to go about this. I would suggest asking KindeAI how to do this in the #⚡⏐ask-kinde-ai channel. Let me know if you have any issues.
Want results from more Discord servers?
Add your server
More Posts