Any way to access users and roles in an API endpoint?

Product: PowerShell Universal
Version: 2.1.2

I need to be able to access the currently logged on user at a bare minimum from an API endpoint. If there is a way to start an API endpoint from within a dashboard, that may help. I need to be able to generate and return a JWT token (only the token) based on the user currently accessing the dashboard. Is there any way to do this currently? I know how to access this info from within a dashboard, but these same variables (user, role) do not seem to be available from within an API endpoint, even when auth is enabled and I am using the same browser session as I am using for the dashboard.

Thanks

Hi, I think you can get the username with the builtin variable $Identity.