I have a SPA with a backend API protected by Keycloak. I want to allow the SPA users to execute actions against the API programmatically instead of only via the SPA. Typically an application would allow a user to "create an API key" and perform actions against the API.
What is the recommended way of doing this with Keycloak?
My current plan is to enable Direct Access Grants (Resource Owner Password Credentials Grant) on the public client and instruct the SPA user to retrieve an Access Token doing:
curl -u public-client: -X POST \
https://keycloak.url/auth/realms/REALM/protocol/openid-connect/token \
-d 'grant_type=password&username=USER&password=PASSWORD'
The user can then access the API using her Access Token. It works but it doesn't feel quite right.
Is there a better (easy!) way? Thanks in advance!