RapidMiner : Can't get JWT Token

97 Views Asked by At

I am refering below document to get JWT Token . However when I call the API /api/rest/tokenservice it doesn't return the token but returns a web interface asking for login . How can I get JWT Token

REST API Url : https://docs.rapidminer.com/9.10/hub/rest-api/index.html

enter image description here

Response of postman:

enter image description here

1

There are 1 best solutions below

0
David On

In order to query the internal tokenservice endpoint, you need a valid "session". In the native installation method, you can use basic auth as "session" as outlined in the documentation.

curl -u user:pass "http://localhost:8080/api/rest/tokenservice"

{
  "idToken": "the-valid-token",
  "expirationDate": "the-exp"
}

However, for this to work when you've deployed RapidMiner AI Hub with Keycloak (and docker), you need to 1. enable basic auth for Keycloak, 2. access the route by first having a valid "login session" (cookie name is RM_SERVER_JSESSIONID) or 3. use a valid Keycloak token.

Enable basic auth in Keycloak

rm-server-homedir/configuration/keycloak/keycloak.json

{
...
"enable-basic-auth": true,
...
}

Valid cookie value

Login via web interface, open the browser's developer tools and use the very same RM_SERVER_JSESSIONID cookie value inside the REST request issued to the /api/rest/tokenservice endpoint. Not sure what you like to achieve, e.g. schedule a process via REST, I like to outline that you can easily add a process and trigger via Web Service. The triggered process could make use of the Admin Tools extension. You still need to enable Keycloak's basic auth though if you like to trigger it from "outside". A guide how to use the extension can be found here.

Valid Keycloak token Retrieve a valid Keycloak access token (from Keycloak's token endpoint, e.g. via OpenID Connect) and query the /api/rest/tokenservice endpoint with Authorization: Bearer .

Disclaimer: This answer is used with permission of the original author from the RapidMiner community.