-
Notifications
You must be signed in to change notification settings - Fork 40
Expand file tree
/
Copy pathclients-get.php
More file actions
31 lines (21 loc) · 1.01 KB
/
Copy pathclients-get.php
File metadata and controls
31 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?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();
$resource = $keycloak->clients();
$clients = $keycloak->clients()->all(realm: 'master');
$client = $keycloak->clients()->get('master', $clients->first()->getId());
echo sprintf('Client "%s" (%s) has the following redirect URIs:%s', $client->getClientId(), $client->getId(), PHP_EOL);
foreach ($client->getRedirectUris() as $redirectUri) {
echo sprintf('-> Redirect URI "%s"%s', $redirectUri, PHP_EOL);
}
$userSessions = $resource->getUserSessions('master', $client->getId());
echo sprintf('Client "%s" (%s) has the following %d user sessions:%s', $client->getClientId(), $client->getId(), count($userSessions), PHP_EOL);
foreach ($userSessions as $userSession) {
print_r($userSession);
}