Pako
Pako

Reputation: 439

Keycloak JAX-RS and Postman Authorization (Auth URL)

I have resources with jax-rs and use keycloak I want to get the token with Postman

this is the database client for jax-rs (keycloak-quickstart)

{
  "realm": "demo",
  "bearer-only": true,
  "auth-server-url": "http://localhost:8080/auth",
  "ssl-required": "external",
  "resource": "database-service"
}

I created a client for Postman

{
  "realm": "demo",
  "auth-server-url": "http://localhost:8080/auth",
  "ssl-required": "external",
  "resource": "client-postman",
  "credentials": {
    "secret": "b53f32d3-e15b-474b-a88d-1f1cfa68c2dc"
  }
}

I chose the OAuth 2.0 type enter image description here

The url for the access token is

http://localhost:8080/auth/realms/demo/protocol/openid-connect/token

But I do not know what the auth url is enter image description here

Upvotes: 12

Views: 19417

Answers (2)

dmnk_89
dmnk_89

Reputation: 497

with current version of Postman and keycloak 2.2.1.Final i've managed to setup OAuth 2.0

Postman setup for keycloak

Client Secret: not required but AFAIK you cane have it setup in client and then you have to provide it here

Auth Url: https://{KEYCLOAK}/auth/realms/{REALM}/protocol/openid-connect/auth

Token Url: https://{KEYCLOAK}/auth/realms/{REALM}/protocol/openid-connect/token

You can get those urls from https://{KEYCLOAK}/auth/realms/{REALM}/.well-known/openid-configuration

Upvotes: 29

Pako
Pako

Reputation: 439

I managed to receive the token but I do not know how to call the jax-rs resources

I set it in keycloak:

Direct Access Grants Enabled: ON
Service Accounts Enabled : ON

enter image description here

and the postman request enter image description here

Now that I have the token I can call resources by setting the jaxrs url and in the header Authorization: bearer [my token]

enter image description here

Now I would like to use Postman's Authorization function to speed up the steps and call resources directly, but I do not know if it's possible

Upvotes: 1

Related Questions