Keycloak service to service

Viewed 2594

I have a secured architecture with Keycloak (see Securing thorntail service with KEYCLOAK for schema). It works well. But now, I can't figure out how to make service A getting some info from secured Service B, alone.

If the flow is FrontEnd (authenticated, so has a token) / service A / secured Service B then Ok, A access B. But, for example first time in the morning (@startup) service A needs to get some infos from service B, no token to forward ... how to do it ?

1 Answers

Client Credentials Flow is what you need. https://www.keycloak.org/docs/latest/authorization_services/#_service_protection_permission_api_papi

curl -X POST \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -d 'grant_type=client_credentials&client_id=${client_id}&client_secret=${client_secret}' \
    "http://localhost:8080/auth/realms/${realm_name}/protocol/openid-connect/token"

This is from keycloak documentation (https://www.keycloak.org/docs/latest/authorization_services/#_service_protection_permission_api_papi).

Check also this: https://auth0.com/docs/flows/concepts/client-credentials

Related