You can run that code snippet without running a Web Container. Just replace
"session.getTokenString()" with
"Keycloak.tokenManager().getAccessTokenString()"
On Mon, Oct 10, 2016 at 8:16 AM, Charles Moulliard <cmoullia(a)redhat.com>
wrote:
Thx Seb. The code you proposed supposes that we will run the
application
with a HttpContainer.
My question is related to a Java Client not running in a Web or JavaEE
container
On Fri, Oct 7, 2016 at 7:55 PM, Sebastien Blanc <sblanc(a)redhat.com> wrote:
> 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/de
> mo-template/product-app/src/main/java/org/keycloak/example/
> oauth/ProductDatabaseClient.java#L58-L80
>
> And use your String here :
https://github.com/keycloak/ke
> ycloak/blob/master/examples/demo-template/product-app/src/ma
> in/java/org/keycloak/example/oauth/ProductDatabaseClient.java#L61
>
>
>
>
> On Fri, Oct 7, 2016 at 7:37 PM, Charles Moulliard <cmoullia(a)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/integr
>> ation/admin-client/src/main/java/org/keycloak/admin/client/Keycloak.java
>>
>> Regards
>>
>> Charles
>> _______________________________________________
>> keycloak-user mailing list
>> keycloak-user(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/keycloak-user
>>
>
>