# Getting current users accountId

**URL:** <https://community.developer.atlassian.com/t/getting-current-users-accountid/45932>\
**Category:** Jira Cloud\
**Tags:** applicationuser, ac-spring-boot, java, jira-cloud, rest-api\
**Created:** [March 9, 2021, 9:15am UTC](https://community.developer.atlassian.com/t/getting-current-users-accountid/45932 "2021-03-09T09:15:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![TaaviTilgre](https://avatars.discourse-cdn.com/v4/letter/t/eb8c5e/32.png) [@TaaviTilgre](https://community.developer.atlassian.com/u/TaaviTilgre)\
**Post date:** [March 9, 2021, 9:15am UTC](https://community.developer.atlassian.com/t/getting-current-users-accountid/45932/1 "2021-03-09T09:15:13Z")

</div>

Hi

I needt current users accountId.  
I am trying to get it from ‘myself’ resurse for currently logged in user by jira cloud rest api, but i can’t find a way to make it happen.

`AtlassianHostRestClients.authenticatedAsAddon().getForObject(urir, String.class);`  
returns the addon information and  
`AtlassianHostRestClients.authenticatedAsHostActor().getForObject(uri, String.class);`  
returns an error:

> Was asked to authenticate the rest client as the current acting user on the host, but none could be inferred from the current request

Is there a better way to find currently logged in users accountId?

---

<div class="post-metadata">

**Author:** ![anon21029823](https://avatars.discourse-cdn.com/v4/letter/a/7ea924/32.png) [@anon21029823](https://community.developer.atlassian.com/u/anon21029823)\
**Post date:** [March 9, 2021, 10:41am UTC](https://community.developer.atlassian.com/t/getting-current-users-accountid/45932/2 "2021-03-09T10:41:51Z")

</div>

Hi @TaaviTilgre,

This sounds a lot like you are using [atlassian-connect-spring-boot](https://bitbucket.org/atlassian/atlassian-connect-spring-boot/src/master/) for your app? As mentioned in the README, you can let it inject an `AtlassianHostUser` into your REST Controller methods:

```auto
@Controller
public class HelloWorld {

    @RequestMapping(value = "/hello-world", method = RequestMethod.GET)
    @ResponseBody
    public String helloWorld(@AuthenticationPrincipal AtlassianHostUser hostUser) {
        return "hello-world";
    }
}

```

Hope this helps!

Cheers,  
Sven

---

<div class="post-metadata">

**Author:** ![liumulin](https://avatars.discourse-cdn.com/v4/letter/l/6f9a4e/32.png) [@liumulin](https://community.developer.atlassian.com/u/liumulin)\
**Post date:** [February 16, 2023, 6:31am UTC](https://community.developer.atlassian.com/t/getting-current-users-accountid/45932/3 "2023-02-16T06:31:46Z")

</div>

How can I solve the same error when I call the rest api in a scheduled task?
