[keycloak-user] Scenario : Java Client (get a token) -> call a Rest service (control token) --> accept/refuse

Sebastien Blanc sblanc at redhat.com
Fri Oct 7 13:55:03 EDT 2016


You can use :

Keycloak.tokenManager().getAccessTokenString()

An then you pass it in the header of your request , for instance :

https://github.com/keycloak/keycloak/blob/master/examples/demo-template/product-app/src/main/java/org/keycloak/example/oauth/ProductDatabaseClient.java#L58-L80

And use your String here :
https://github.com/keycloak/keycloak/blob/master/examples/demo-template/product-app/src/main/java/org/keycloak/example/oauth/ProductDatabaseClient.java#L61




On Fri, Oct 7, 2016 at 7:37 PM, Charles Moulliard <cmoullia at redhat.com>
wrote:

> Hi,
>
> I would like in a project to perform the following scenario
>
> A Java HTTP Client calls a HTTP Endpoint exposed by WildFly Swarm where the
> address URL ("/rest/say") of the endpoint is secured using Keycloak WildFly
> plugin (keycloak.json contains the OIC).
>
> In order at the client side to get the OpenID token that I must send next
> to the endpoint using "Authentication: Bearer", is it this class that I
> must use to get an instance of Keycloak
>
> Keycloak.getInstance("http/localhost:8080/auth",realm, username, password,
> clientId)
>
>  & next the token to send
>
> Keycloak.tokenManager().grantToken();
>
> ?
>
> Class -->
> https://github.com/keycloak/keycloak/blob/2.2.1.Final/
> integration/admin-client/src/main/java/org/keycloak/admin/
> client/Keycloak.java
>
> Regards
>
> Charles
> _______________________________________________
> keycloak-user mailing list
> keycloak-user at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/keycloak-user
>


More information about the keycloak-user mailing list