# Okta - Add User details&token info to security context

**URL:** <https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549>\
**Category:** Questions\
**Created:** [May 28, 2020, 2:56pm UTC](https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549 "2020-05-28T14:56:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![worldcoder](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@worldcoder](https://devforum.okta.com/u/worldcoder)\
**Post date:** [May 28, 2020, 2:56pm UTC](https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549/1 "2020-05-28T14:56:16Z")

</div>

I have implemented Okta signin widget with Javascript (@okta/okta-signin-widget). Now i can see all user&token info in localstorage as okta-cache-storage and okta-token-storge I want to set this same to Spring Security context(Bacically i want to retain same info for resource server). I know there are some API’s which i can trigger from Resource server but i am looking something effectuate way and can be called only once.-- Thanks for help

---

<div class="post-metadata">

**Author:** ![mraible](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/mraible/32/37_2.png) [@mraible](https://devforum.okta.com/u/mraible)\
**Post date:** [May 28, 2020, 3:34pm UTC](https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549/2 "2020-05-28T15:34:04Z")

</div>

I can see two ways of doing this. 1) You create a bunch of claims that you stuff in your access token. On the Spring side of things, you parse those claims and update the authenticated user. 2) You look up the user’s information on the Spring side using the access token and the `/userinfo` endpoint.

In the end, I think #2 is the best long-term solution. However, I’ve only implemented #1 myself.

---

<div class="post-metadata">

**Author:** ![worldcoder](https://avatars.discourse-cdn.com/v4/letter/w/41988e/32.png) [@worldcoder](https://devforum.okta.com/u/worldcoder)\
**Post date:** [May 29, 2020, 12:32am UTC](https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549/3 "2020-05-29T00:32:49Z")

</div>

Thanks. that hint was helpful. I kind of used below config and got the claim info in the security context now.  
resource:  
user-info-uri: https://dev-\*\*\*.okta.com/oauth2/default/v1/userinfo  
spring-security-oauth2-autoconfigure’, version: '2.0.0.RELEASE

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/oktadev/original/1X/589c4c5f80de422d01f47cee7185a7fb8227835c.png) [@system](https://devforum.okta.com/u/system)\
**Post date:** [January 24, 2024, 7:57pm UTC](https://devforum.okta.com/t/okta-add-user-details-token-info-to-security-context/9549/4 "2024-01-24T19:57:19Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
