Hello all, how can I add metadata to my users? For...
# support-questions
a
Hello all, how can I add metadata to my users? For a SaaS app I want to be able to add an orgId as well as role. I thought I had found something for role but can't seem to find it again
r
Hey! We have APIs exposed by the core for adding user metadata: https://app.swaggerhub.com/apis/supertokens/CDI/2.13.0#/User%20Metadata%20Recipe The backend SDKs have not been updated yet to add helper functions around these APIs, but you can call them directly using axios or node-fetch.
a
So, what does the workflow look like with this? I'm using EmailPassword recepie. The user signsup on the frontend (I also need to be able to invite users from within the app, but that is for later). I then attach the metadata using the userId from the backend. How does the frontend then get the metadata?
Would the getUserInfo provide the user metadata?
r
The backend can retrieve the metadata for the userId using the API from the above spec, and you can send that to the frontend in a couple of ways: - Create an API on the backend that verifies the user's session -> gets the user id -> queries the core to get the meta data -> send it to the frontend; OR - Store the metadata in the access token's payload and retrieve that on the frontend without an API call. The downside to this approach is that the access token's side increases to contain whatever you are putting in it, so use this method only if you need to get the metadata often on the frontend.
6 Views