-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_client.php
More file actions
38 lines (29 loc) · 1.15 KB
/
test_client.php
File metadata and controls
38 lines (29 loc) · 1.15 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
32
33
34
35
36
37
<?php
require_once 'vendor/autoload.php';
use SolidOidc\SolidOidcClient;
use SolidOidc\SolidOidcException;
// Test configuration (replace with actual values)
$issuerUrl = 'https://solidcommunity.net';
$clientId = 'test-client-id';
$clientSecret = 'test-client-secret';
$redirectUri = 'http://localhost:8080/callback';
try {
echo "Creating SolidOidcClient...\n";
$client = new SolidOidcClient($issuerUrl, $clientId, $clientSecret, $redirectUri);
echo "Performing discovery...\n";
$client->discover();
echo "Discovery successful!\n";
echo "Generating authorization URL...\n";
$state = bin2hex(random_bytes(16));
$authUrl = $client->getAuthorizationUrl($state, ['openid', 'profile']);
echo "Authorization URL: " . $authUrl . "\n";
echo "\nTest completed successfully!\n";
} catch (SolidOidcException $e) {
echo "SolidOidc Error: " . $e->getMessage() . "\n";
echo "Error Code: " . $e->getErrorCode() . "\n";
if ($e->getContext()) {
echo "Context: " . json_encode($e->getContext(), JSON_PRETTY_PRINT) . "\n";
}
} catch (Exception $e) {
echo "General Error: " . $e->getMessage() . "\n";
}