21 Nov 2024 01:50 PM
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?
Solved! Go to Solution.
21 Nov 2024 03:48 PM
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.
21 Nov 2024 03:54 PM
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
21 Nov 2024 03:57 PM
Hello @imsingh
Thanks
I would like to fetch it from a Python script, for this reason I cannot use the SDK. 😞
21 Nov 2024 04:11 PM
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"}
21 Nov 2024 04:13 PM
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 ?
25 Nov 2024 11:20 AM
Hi flomaz,
the permission should be app-engine:apps:run. Can you check if you have it?
25 Nov 2024 12:33 PM - edited 25 Nov 2024 12:34 PM
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": ""
}
}
}
01 Dec 2024 10:12 PM
Hi flomaz,
thanks for the patience. We're currently working on fixing this. I'll update you as soon as I have new info.