# Retrieving name of current user with API

**URL:** <https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006>\
**Category:** Developer Q&A Forum\
**Created:** [November 21, 2024, 1:50pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006 "2024-11-21T13:50:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![flomaz](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@flomaz](https://community.dynatrace.com/u/flomaz)\
**Post date:** [November 21, 2024, 1:50pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/1 "2024-11-21T13:50:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![haris](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/haris/32/38293_2.png) [@haris](https://community.dynatrace.com/u/haris)\
**Post date:** [November 21, 2024, 3:48pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/2 "2024-11-21T15:48:07Z")

</div>

Hi flomaz,

we already have an SDK released earlier this year for this purpose. Please see:&nbsp;[App environment | Dynatrace Developer](https://developer.dynatrace.com/develop/sdks/app-environment/)

You can also check this thread with more information:&nbsp;[https://community.dynatrace.com/t5/Developer-Q-A-Forum/Dynatrace-App-Current-user-information/m-p/218433](https://community.dynatrace.com/post/218433)

Let me know if you need anything else.

---

<div class="post-metadata">

**Author:** ![imsingh](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/imsingh/32/7858_2.png) [@imsingh](https://community.dynatrace.com/u/imsingh)\
**Post date:** [November 21, 2024, 3:54pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/3 "2024-11-21T15:54:52Z")

</div>

Hi there

You can use the&nbsp;[@dynatrace-sdk/app-environment](https://www.npmjs.com/package/@dynatrace-sdk/app-environment)&nbsp;sdk to get the user details as following:

```javascript
// 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

---

<div class="post-metadata">

**Author:** ![flomaz](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@flomaz](https://community.dynatrace.com/u/flomaz)\
**Post date:** [November 21, 2024, 3:57pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/4 "2024-11-21T15:57:57Z")

</div>

Hello [@imsingh](https://community.dynatrace.com/user/52863)

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

---

<div class="post-metadata">

**Author:** ![haris](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/haris/32/38293_2.png) [@haris](https://community.dynatrace.com/u/haris)\
**Post date:** [November 21, 2024, 4:11pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/5 "2024-11-21T16:11:25Z")

</div>

Hi flomaz,

can you try using this:

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

```

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

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

```

---

<div class="post-metadata">

**Author:** ![flomaz](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@flomaz](https://community.dynatrace.com/u/flomaz)\
**Post date:** [November 21, 2024, 4:13pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/6 "2024-11-21T16:13:49Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![haris](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/haris/32/38293_2.png) [@haris](https://community.dynatrace.com/u/haris)\
**Post date:** [November 25, 2024, 11:20am UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/7 "2024-11-25T11:20:36Z")

</div>

Hi flomaz,

the permission should be&nbsp; **app-engine:apps:run**. Can you check if you have it?

---

<div class="post-metadata">

**Author:** ![flomaz](https://avatars.discourse-cdn.com/v4/letter/f/0ea827/32.png) [@flomaz](https://community.dynatrace.com/u/flomaz)\
**Post date:** [November 25, 2024, 12:33pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/8 "2024-11-25T12:33:21Z")

</div>

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”: “”  
> }  
> }  
> }

---

<div class="post-metadata">

**Author:** ![haris](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/haris/32/38293_2.png) [@haris](https://community.dynatrace.com/u/haris)\
**Post date:** [December 1, 2024, 10:12pm UTC](https://community.dynatrace.com/t/retrieving-name-of-current-user-with-api/49006/9 "2024-12-01T22:12:58Z")

</div>

Hi flomaz,

thanks for the patience. We’re currently working on fixing this. I’ll update you as soon as I have new info.
