Tools for interfacing with the Keycloak API
This repository is the very initial outline for interfacing with the Keycloak account_api.
To add this to your project:
composer require aria-php/keycloak-api
This API wrapper supports the ability to:
- Retrieve the profile of your user (as identified by your
access_tokensent as a bearer token)
- Update the profile
- Set the user's password
use ARIA\KeycloakAPI\AccountAPI; ... $api = new AccountAPI($client_id, $secret, 'master', 'http://localhost:8080'); $api->setBearer($access_token); $profile = $api->getProfile(); // Make your updates here $api->setProfile($profile);
Your user is identified by obtaining an access token from keycloak for the user, and then passing it as a bearer token.
Note: this is the
access_token, not the
In order to run the unit tests you need to set up some environment variables:
KEYCLOAK_USERis the user you're trying to connect to
KEYCLOAK_REALMthe keycloak realm (e.g. "master")
KEYCLOAK_CLIENT_IDthe keycloak client id (e.g. "account")
KEYCLOAK_SECRETthe client secret
KEYCLOAK_BASEURLthe base URL, e.g. "http://localhost:8080"
You will also need to enable "Direct access grants" for your client.
LGPLv3 - Please see LICENSE.txt for details.