Skip to content

Commit 177635e

Browse files
committed
Update README for authorization metadata
1 parent 303e7f9 commit 177635e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,35 @@ authorization" request. Another example is the client credentials flow,
2626
where an access token is stored in the authorizations table which is
2727
needed for executing authorized requests to the respective service.
2828

29+
Authorizations also may contain developer-provided metadata. For
30+
example, you may attach an account identifier to an authorization when
31+
an authorization process starts and use that information when
32+
authorization finishes to make sure that the authorization is only used
33+
for a specific account (or customer number, or participant id).
34+
35+
To set metadata, you need to know the authorization id when starting the
36+
authorization code flow. This code could be used in an overloaded
37+
`startAuthorizationAction()`:
38+
39+
```php
40+
$authorizationId = $oAuthClient->generateAuthorizationIdForAuthorizationCodeGrant($this->appId);
41+
$loginUri = $oAuthClient->startAuthorizationWithId(
42+
$authorizationId,
43+
$this->appId,
44+
$this->appSecret,
45+
$returnToUri,
46+
$scope
47+
);
48+
$oAuthClient->setAuthorizationMetadata($authorizationId, json_encode($metadata));
49+
```
50+
And later, in `finishAuthorization()`, you may retrieve the metadata as
51+
follows:
52+
53+
```php
54+
$authorization = $this->getAuthorization($authorizationId);
55+
$metadata = json_decode($authorization->getMetadata());
56+
```
57+
2958
## Encryption
3059

3160
By default, access tokens are serialized and stored unencrypted in the

0 commit comments

Comments
 (0)