cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Retrieving name of current user with API

flomaz
Participant

Hi,

I'm trying to get the current user name and id using the platform API with a platform token.

I've checked the Swagger UI for the `Identity and Access Management` but did not find any solution.

Is there an API available for fetching the medata of the owner of the platform token without administrator permissions?

5 REPLIES 5

haris
Dynatrace Helper
Dynatrace Helper

Hi flomaz,

we already have an SDK released earlier this year for this purpose. Please see: https://developer.dynatrace.com/develop/sdks/app-environment/

 

You can also check this thread with more information: https://community.dynatrace.com/t5/Developer-Q-A-Forum/Dynatrace-App-Current-user-information/m-p/21...

 

Let me know if you need anything else. 

imsingh
Dynatrace Advisor
Dynatrace Advisor

Hi there

You can use the @dynatrace-sdk/app-environment sdk to get the user details as following:

// import the function
import { getCurrentUserDetails } from "@dynatrace-sdk/app-environment";

// get the user details
const userDetails = getCurrentUserDetails();

// do something wit it
console.log(userDetails);


Thanks

Indermohan Singh

Hello @imsingh

Thanks
I would like to fetch it from a Python script, for this reason I cannot use the SDK. 😞

haris
Dynatrace Helper
Dynatrace Helper

Hi flomaz,

can you try using this:

https://{environmentid}.apps.dynatrace.com/platform/metadata/v1/user

This should return json with following info: username, ID and email address like so:

{"userName":"Haris H","userId":"621321d-1231-dsad-652321829b50","emailAddress":"haris.h@dynatrace.com"}

Hello Haris,
Thanks, do you know if there are any permission to add to use this api ?
I've tried this url but I do get 403. Is there any specific scope that I should add to the platform token ?

Featured Posts