flomaz
November 21, 2024, 1:50pm
1
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?
haris
November 21, 2024, 3:48pm
2
Hi flomaz,
we already have an SDK released earlier this year for this purpose. Please see: App environment | Dynatrace Developer
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/218433
Let me know if you need anything else.
imsingh
November 21, 2024, 3:54pm
3
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
flomaz
November 21, 2024, 3:57pm
4
Hello @imsingh
Thanks
I would like to fetch it from a Python script, for this reason I cannot use the SDK.
haris
November 21, 2024, 4:11pm
5
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"}
flomaz
November 21, 2024, 4:13pm
6
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 ?
haris
November 25, 2024, 11:20am
7
Hi flomaz,
the permission should be app-engine:apps:run . Can you check if you have it?
flomaz
November 25, 2024, 12:33pm
8
Hi Haris,
Thanks, I’ve created a new platform token with the permission `app-engine:apps:run ` and now I get a http 500.
{
“error”: {
“code”: 500,
“message”: “Internal Server Error occurred.”,
“details”: {
“errorRef”: “”,
“traceId”: “”
}
}
}
haris
December 1, 2024, 10:12pm
9
Hi flomaz,
thanks for the patience. We’re currently working on fixing this. I’ll update you as soon as I have new info.