# How to get user info after validating JWT token?

**URL:** <https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397>\
**Category:** Get Help\
**Tags:** jwt, auth0\
**Created:** [June 9, 2020, 7:25pm UTC](https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397 "2020-06-09T19:25:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![to.jontan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/to.jontan/32/21820_2.png) [@to.jontan](https://community.auth0.com/u/to.jontan)\
**Post date:** [June 9, 2020, 7:25pm UTC](https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397/1 "2020-06-09T19:25:31Z")

</div>

I have followed this tutorial ([Java Springboot API - Auth0 Docs](https://auth0.com/docs/quickstart/backend/java-spring-security5/01-authorization)) and successfully created working authentication flow for my Java API backend.

```auto
    @GetMapping("/posts")
    fun String(): getPosts: List<String> {
        val userId: String = "google-oauth2|108335805846181510876"
        val posts: List<String> = postDao.listPosts(userId);
        return posts;
    }

```

How should I get the userId from the token?

---

<div class="post-metadata">

**Author:** ![to.jontan](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/to.jontan/32/21820_2.png) [@to.jontan](https://community.auth0.com/u/to.jontan)\
**Post date:** [June 9, 2020, 7:35pm UTC](https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397/2 "2020-06-09T19:35:53Z")

</div>

Hehe got it.

```auto
@GetMapping("/posts")
    fun String(authentication: Authentication): getPosts: List<String> {
        val userId: String = authentication.name
        val posts: List<String> = postDao.listPosts(userId);
        return posts;
    }

```

Reference:

- [https://www.baeldung.com/get-user-in-spring-security](https://www.baeldung.com/get-user-in-spring-security)

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 9, 2020, 10:25pm UTC](https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397/3 "2020-06-09T22:25:55Z")

</div>

Glad you figured it out!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [June 10, 2020, 11:11am UTC](https://community.auth0.com/t/how-to-get-user-info-after-validating-jwt-token/44397/4 "2020-06-10T11:11:03Z")

</div>


