Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot Oauth2 - Where is the access token stored?

I have a jhipster (spring boot and angular) project implementing oauth2 protocol with Keycloak. I managed to get the application to redirect to keycloak for authentication. I am quite confused as to where the access token is in the response after sign in and where is it stored after redirecting back to my site? I tried using chrome inspect to view the network but I can't seem to find the access token.

Below is a link I used to setup oauth2 for my project: https://www.jhipster.tech/security/

URL when login is clicked: http://localhost:8080/oauth2/authorization/oidc

like image 380
user2473078 Avatar asked Sep 13 '25 16:09

user2473078


1 Answers

Thanks for all the reply. Managed to get the tokens using the following:

SecurityContext securityContext = SecurityContextHolder.getContext();
    OAuth2AuthenticationToken oauth2Token = (OAuth2AuthenticationToken) 
securityContext.getAuthentication();

OAuth2AuthorizedClient client = clientService
            .loadAuthorizedClient(oauth2Token.getAuthorizedClientRegistrationId(), 
oauth2Token.getName());

refreshToken = client.getRefreshToken().getTokenValue();
like image 77
user2473078 Avatar answered Sep 17 '25 01:09

user2473078