Hi Pavel,
KeycloakSecurityContext has a parseToken() method just for that, but it's private for
some reasons. However it's trivial, so you can easily borrow those six lines :)
Cheers,
Dmitry
On Sat, 2019-02-02 at 19:58 +0100, Pavel Maslov wrote:
Hi Dmitry,
This only gives a string representation of the refresh token. Well, I would like the
expiration date property as well.
Regards,
Pavel Maslov, MS
> On Fri, Feb 1, 2019 at 6:12 PM Dmitry Telegin <dt(a)acutus.pro> wrote:
> Hello Pavel,
>
> Just cast your KeycloakSecurityContext to
org.keycloak.adapters.RefreshableKeycloakSecurityContext and call getRefreshToken().
>
> Udachi :)
> Dmitry Telegin
> CTO, Acutus s.r.o.
> Keycloak Consulting and Training
>
> Pod lipami street 339/52, 130 00 Prague 3, Czech Republic
> +42 (022) 888-30-71
> E-mail: info(a)acutus.pro
>
> On Fri, 2019-02-01 at 16:38 +0100, Pavel Maslov wrote:
> > Hi Niko, all
> >
> > Is it possible to get the refresh token in the same manner?
> > Thanks :)
> >
> > Regards,
> > Pavel Maslov, MS
> >
> >
> > > > > On Fri, Dec 28, 2018 at 12:16 PM Niko Köbler <niko(a)n-k.de>
wrote:
> >
> > > As you can see, the bean definition ist Request-scoped.
> > > This leads to a new bean instance for every request, and thus for each
and
> > > every user :)
> > >
> > >
> > >
> > > Am 28.12.2018 um 11:46 schrieb Pavel Maslov
<pavel.masloff(a)gmail.com>:
> > >
> > > Hey Niko,
> > >
> > > Excellent, this is exactly what I was looking for!
> > > In your example does the *accessToken *injected field return a token for
> > > each and every user respectively (not the same)?
> > > Thank you very "many" (much) :))
> > >
> > > Regards,
> > > Pavel Maslov, MS
> > >
> > >
> > > > > > > On Fri, Dec 28, 2018 at 11:38 AM Niko Köbler
<niko(a)n-k.de> wrote:
> > >
> > > > Hi Pavel,
> > > >
> > > > that's quite easy (as most things with Spring Boot).
> > > >
> > > > You can get the AccessToken object through the HttpServletRequest,
> > > > KeycloakPrincipal and KeycloakSecurityContext.
> > > > In my projects, I do some bean definitions like here:
> > > >
https://github.com/dasniko/keycloak-springboot-demo/blob/master/src/main/...
> > > > Then, you can just inject the AccessToken or KeycloakSecurityContext
> > > > where you want, like this:
> > > >
https://github.com/dasniko/keycloak-springboot-demo/blob/master/src/main/...
> > > >
> > > > Instead of the AccessToken, you can also get the IdentityToken, of
course.
> > > >
> > > > HTH,
> > > > - Niko
> > > >
> > > >
> > > > > Am 28.12.2018 um 11:22 schrieb Pavel Maslov
<pavel.masloff(a)gmail.com>:
> > > > >
> > > > > Hi, guys. Haven't been here for quite a while :)
> > > > >
> > > > >
> > > > > I'm using the Springboot Keycloak adapter
> > > > > (org.keycloak:keycloak-spring-boot-starter:4.6.0.Final) to
secure my
> > > >
> > > > REST
> > > > > API via bearer token [1]. And it works! Cool.
> > > > >
> > > > > Now, I would like to get the access token in my @RestController,
or even
> > > > > better some information about the user. Is it possible?
> > > > >
> > > > > Thanks in advance.
> > > > >
> > > > > Regards,
> > > > > Pavel Maslov, MS
> > > > >
> > > > > [1]
https://github.com/maslick/barkoder
> > > > > _______________________________________________
> > > > > keycloak-user mailing list
> > > > > keycloak-user(a)lists.jboss.org
> > > > >
https://lists.jboss.org/mailman/listinfo/keycloak-user
> > > >
> > > >
> >
> > _______________________________________________
> > keycloak-user mailing list
> > keycloak-user(a)lists.jboss.org
> >
https://lists.jboss.org/mailman/listinfo/keycloak-user
>