docs: handle userinfo invalid_token outcomes in callback example

Update SDK example callback and integration guidance to treat UserInfoException as an authorization-state outcome (e.g. subject disabled/inactive scope) and return a clear 403 path.
This commit is contained in:
Andy Dixon
2026-02-26 11:51:29 +00:00
parent 7bb919a0a0
commit 78a18ccfab
2 changed files with 6 additions and 0 deletions
+2
View File
@@ -134,6 +134,8 @@ try {
} }
``` ```
`UserInfoException` with `invalid_token` can occur when provider-side subject scope is no longer active (for example user/project disabled) between token issuance and userinfo retrieval.
## Operational guidance ## Operational guidance
- Keep provider URLs in environment variables, not hard-coded. - Keep provider URLs in environment variables, not hard-coded.
+4
View File
@@ -16,6 +16,7 @@ foreach ($autoloadCandidates as $file) {
} }
use BlackWallSDK\BlackWallAuth; use BlackWallSDK\BlackWallAuth;
use BlackWall\Auth\Exception\UserInfoException;
$auth = new BlackWallAuth([ $auth = new BlackWallAuth([
'clientId' => '94d228c4-d4c6-4479-9b02-793e6a73e3f2', 'clientId' => '94d228c4-d4c6-4479-9b02-793e6a73e3f2',
@@ -42,6 +43,9 @@ try {
header('Location: /'); header('Location: /');
exit; exit;
} catch (UserInfoException $e) {
http_response_code(403);
echo 'User info access failed: ' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
} catch (Throwable $e) { } catch (Throwable $e) {
http_response_code(500); http_response_code(500);
echo 'Auth failed: ' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); echo 'Auth failed: ' . htmlspecialchars($e->getMessage(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');