title: Get the AccessToken of Keycloak in Spring Boot
body: <p>i used Keycloak for the authorization management in my spring boot application, i get the access token from this curl command:</p>
  
  <pre><code>curl \
   -d "client_id=admin-cli" \
   -d "username=user" \
   -d "password=password" \
   -d "grant_type=password" \
   "http://localhost:8180/auth/realms/SpringBootKeycloak/protocol/openid-connect/token"
  </code></pre>
  
  <p>now i want to get this accessToken in my controller, i tried this <a href="https://www.n-k.de/2016/05/how-to-get-accesstoken-from-keycloak-springboot-javaee.html" rel="nofollow noreferrer">example</a>  but it doesn't seem to be working, It displays this error
  :</p>
  
  <pre><code>org.keycloak.adapters.springsecurity.token.KeycloakAuthenticationToken cannot be cast to org.keycloak.KeycloakPrincipal
  </code></pre>