How to get okta user details/current session once authenticated in JAVA

Hi, In my JAVA web application, i am moving from redhat redhat SSO to OKTA.

I am able to redirect to OKTA server login page when my application URL is hit in the URL.OKTA server is being authenticated with the username and password entered and my application is redirecting to.

Now I am trying to find how to get that authenticated session or authenticated user details in java code.

Any help will be appreciated. Thanks.

Are you using Spring Boot + Spring Security or a similar framework?

No, not using any of those… mine is plain web application which hits Primefaces in the UI via servlet filters.

This blog post might help.

I saw the blog post.
My question is how to get the username in the first place from okta login page. My httprequest in the servlet filter is not having those details. I am getting code and state returned in the response when okta authenticates.

I am not getting active session from okta either.

I am not sure what i am still missing.

I had to call get accesstoken and then call /userinfo endpoint to get the user details.

Hi!

If you are just looking for the username you should be able to retrieve that from the “preferred_username” claim in the ID token. That’s simpler than the second step of going to /userinfo if that is all you are looking for.

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