Charles,
to get the token you have to invoke a REST service, unless you wanna code
low level http calls, you have to use a JAX-RS implementation library.
If you are familiar with CXF (and I know you are ;) ) I created a porting
of Admin Client that use CXF as JAX-RS implementation:
https://github.com/luigidemasi/keycloak-cxf-admin-client
Regards,
Luigi.
2016-10-10 16:50 GMT+02:00 Charles Moulliard <cmoullia(a)redhat.com>:
The client code that you are proposing to use is based the code that
I was
suggesting (= Keycloak Admin Client") ;-)
On Mon, Oct 10, 2016 at 8:47 AM, Sebastien Blanc <sblanc(a)redhat.com>
wrote:
> You can run that code snippet without running a Web Container. Just
> replace "session.getTokenString()" with
"Keycloak.tokenManager()`"
>
> 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/o
>>> auth/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/K
>>>> eycloak.java
>>>>
>>>> Regards
>>>>
>>>> Charles
>>>> _______________________________________________
>>>> 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
--
Luigi De Masi
*"Talk is cheap. Show me the code."*
* -- Linus Torvalds*
------------------------------
RED HAT SALES ENGINEER & DELIVERY SPECIALIST
MIDDLEWARE APPLICATION DEVELOPMENT
Extra S.r.l <
http://www.extrasrl.it/>
Headquarter & Office North Italy: Pontedera (PI) - Via Salvo D'acquisto,
40/P 56025
phone : +39 0587 975820
mobile: +39 392 9448189
fax: +39 0587 975810
skype: l.demasi
web:
http://www.extrasrl.it
Office South Italy: Rende (CS) - Via Pedro Alvares Cabrai - C.da Lecco
87036 Rende (CS)
<
http://www.linkedin.com/company/207447?trk=prof-exp-company-name>
<
https://twitter.com/extrasrl>
The information transmitted is intended for the person or entity to which
it is addressed and may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any
action in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you received this in error, please
contact the sender and delete the material from any computer.
--
------------------------------
Extra srl
p: +39 0587975800
a: Via Salvo D'Acquisto 40/P - 56025 - Pontedera - Italy
<
https://goo.gl/maps/ngs7hecn9By>
w:
www.extrasrl.it e: info(a)extrasys.it
<
https://www.facebook.com/Extra-149813195076455/?fref=ts>
<
https://twitter.com/extrasrl>
<
https://www.linkedin.com/company/extra-srl>
<
https://flipboard.com/@extrasrl/soluzioni-per-il-business-0rk6urr6y>
<
https://www.youtube.com/channel/UCZa_aTznqeh5zoIPKPk1dNg>
<
https://www.redhat.com/it/about/events/red-hat-open-source-day-2016>
Le informazioni trasmesse sono riservate alla persona o ente alla quali
sono indirizzate e possono contenere informazioni riservate e/o materiale
di valore. Qualsiasi revisione, ritrasmissione, diffusione o altro uso, o
l'adozione di azioni basate su tali informazioni da parte di soggetti
diversi dal destinatario รจ proibita. Se avete ricevuto per errore questo
messaggio, siete pregati di informare il mittente e cancellare il materiale
contenuto da ogni computer.
The information transmitted is intended for the person or entity to which
it is addressed and may contain confidential and/or privileged material.
Any review, retransmission, dissemination or other use of, or taking of any
action in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you received this in error, please
contact the sender and delete the material from any computer.