PHP code example of mohammad-waleed / keycloak-admin-client
1. Go to this page and download the library: Download mohammad-waleed/keycloak-admin-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mohammad-waleed / keycloak-admin-client example snippets
use GuzzleHttp\Middleware;
use Psr\Http\Message\RequestInterface;
$client = Keycloak\Admin\KeycloakClient::factory([
...
'middlewares' => [
// throws exceptions when request fails
Middleware::httpErrors(),
// other custom middlewares
Middleware::mapRequest(function (RequestInterface $request) {
return $request;
}),
],
]);
class CustomTokenStorage implements TokenStorage
{
public function getToken()
{
// TODO
}
public function saveToken(array $token)
{
// TODO
}
}
$client = Keycloak\Admin\KeycloakClient::factory([
...
'token_storage' => new CustomTokenStorage(),
]);
$client = KeycloakClient::factory([
...
'custom_operations' => [
'getUsersByAttribute' => [
'uri' => '/auth/realms/{realm}/userapi-rest/users/search-by-attr',
'description' => 'Get users by attribute Returns a list of users, filtered according to query parameters',
'httpMethod' => 'GET',
'parameters' => [
'realm' => [
'location' => 'uri',
'description' => 'The Realm name',
'type' => 'string',
'
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.