Unclear how to get the current user's information in my API


this is more or less a stupid question now, but how can I get the current user’s information in my API?

I followed the following tutorial: Tutorial
and here I’m told to use req.user:

which doesn’t exist in my request object anymore, instead there is req.auth.
However, this object only contains the following properties:

The only thing I see in this object that would be relevant is the user ID of the current user, what is the correct procedure here?

Do I need to call the management API from my API to get the info like the name, send my user object from the client or do I need to change something in the user or app metadata here?

It would be great if someone could help me here.

Thanks in advance!

Hello @manuel.poelzl1 !

Hmm I think the docs might be mistaken in that all I would expect to see here is req.auth - Typically, the user profile information is derived from the ID token which is not an option here given that the API only deals with the access token (which you see in req.auth). That being said, you have 2 main options:

Hope this helps!

1 Like

Hi @tyf

I took the approach where I add a custom claim to the token, now everything works!
Thank you very much for solving my problem!

1 Like

Awesome, thanks for the update :slight_smile: Happy to help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.