Adding supplementary user data
-
Hello FusionAuth Forums,
I just spun up FA and i am starting to integrate it with the applicaitons that Im building but there are two things that im having trouble understanding. One is is how to add other data or connect fusionauth to another database or tables with other data. What I mean is that I am integrating stripe into my application to handle paying for subscriptions. So for that I am needing to store the stripe customer id as well as other data. There are 2 approaches in my mind and I dont know the feasability of them so I came here looking for pointers/guidance/help.My 2 thoughts of how to accomplish this are:
- Adding fields into fusion auth that will handle the supplementary user information that I want to add
- Somehow doing a relationship between how fusion auth stores user data in its database and the database with the other associated user information
My second thing is custom grouping associated with users. SO Being able to say user X is part of a team. Granted a team is custom defined by my application. I guess im just struggling after looking through the docs is seeing how to take the user data from FusionAuth and connecting it to other data about users that I plan on having. Any guidance is greatly appreciated to how I accomplish this
-
@evanm I would recommend using a JWT in your API and storing the user id to associate the user to your stripe user account.
You can find more about this in our tokens docs, here you will want the sub.
https://fusionauth.io/docs/lifecycle/authenticate-users/oauth/tokens
On point two it is a classic it depends scenario. This could be handled by logic that you build, or if it makes sense you could use FusionAuth's groups or entities
-
@Alex-Patterson
So a user can be associated with many teams
Reading the groups documentation the first line shows it may not be necessairly what im looking for
A FusionAuth Group is a named object that optionally contains one to many Application Roles. - Its not used for role access, It more for organization within the app. Right now I cant use entities because Im deving on the free plan. What Im probably gonna have todo is have all the users managed under FA and then get the unique ID from each user and then do the relationships in my apps logic. -
@Alex-Patterson
Following up. Im trying to figure out how to architect this as I want to be able to relate a vast amount of external data to the user from fusion auth. There are various other db tables that contain data that need to be related back to users stored in fusion auth. Is there any kind of unique Identifier that I can draw from fusionauth and save in the tables or any way to make database relationships back to fusion auth? -
@evanm Yes you can use the
sub
inside of the JWT when making any API call to your backend. In your database this will be a unique Id for the user. You can even get more details about the user from FusionAuth by calling the User endpoints.