Files
blackwall-auth-sdk/docs/MIGRATION.md
T
2026-03-11 07:41:21 +00:00

38 lines
1.3 KiB
Markdown

# Migration Guide
## Moving from `BlackWallSDK\BlackWallAuth` to `BlackWall\Auth\AuthClient`
### Before
```php
$auth = new BlackWallSDK\BlackWallAuth($config);
$authData = $auth->getAuthorizationUrl();
$tokens = $auth->exchangeCodeForTokens($code);
$user = $auth->getUserInfo($tokens['access_token']);
```
### After
```php
use BlackWall\Auth\AuthClient;
use BlackWall\Auth\Config;
$client = new AuthClient(Config::fromArray($config));
$authData = $client->buildAuthorisationUrl();
$tokens = $client->exchangeCodeForTokens($code);
$user = $client->getUserInfo($tokens->accessToken);
```
## Key differences
- Method spelling uses British English in the new API: `buildAuthorisationUrl()`.
- The legacy method name `getAuthorizationUrl()` is unchanged for backwards compatibility.
- Token responses are strongly typed via `TokenSet`.
- Errors are represented by specific exception classes.
- HTTP transport is swappable via `HttpClientInterface`.
- OIDC nonce handling is now first-class: `buildAuthorisationUrl()` returns `nonce`, persists it in session by default, and `handleCallback()` can validate it against the returned `id_token`.
## Compatibility status
`BlackWallSDK\BlackWallAuth` remains available and delegates to the new client. Existing applications can upgrade gradually.