forked from fschmtt/keycloak-rest-api-client-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclients-all.php
More file actions
24 lines (16 loc) · 683 Bytes
/
Copy pathclients-all.php
File metadata and controls
24 lines (16 loc) · 683 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
declare(strict_types=1);
use Fschmtt\Keycloak\Builder;
use Fschmtt\Keycloak\OAuth\GrantType;
require_once __DIR__ . '/../vendor/autoload.php';
$keycloak = (new Builder())
->withBaseUrl($_SERVER['KEYCLOAK_BASE_URL'] ?? 'http://keycloak:8080')
->withGrantType(GrantType::password('admin', 'admin'))
->build();
$realm = $keycloak->realms()->get('master');
$resource = $keycloak->clients();
$clients = $keycloak->clients()->all(realm: $realm->getRealm());
echo sprintf('Realm "%s" has the following clients:%s', $realm->getRealm(), PHP_EOL);
foreach ($clients as $client) {
echo sprintf('-> %s (%s)%s', $client->getClientId(), $client->getId(), PHP_EOL);
}