Skip to content

Commit 8540c72

Browse files
committed
Merge branch '2.10.x' into qa/merge-up-2.10.1
2 parents 5a52c38 + 1c1a4b2 commit 8540c72

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/book/v1/authorization-server.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ use Mezzio\Authentication\OAuth2;
2121
$app->post('/oauth2/token', OAuth2\TokenEndpointHandler::class);
2222
```
2323

24+
## Parsing JSON payloads in the token endpoint
25+
26+
To enable the token endpoint to handle the POST requests in JSON, the [Body Parsing Middleware](https://docs.mezzio.dev/mezzio/v3/features/helpers/body-parse/) helper must be included in the application.
27+
28+
For example:
29+
30+
```php
31+
use Mezzio\Authentication\OAuth2;
32+
use Mezzio\Helper\BodyParams\BodyParamsMiddleware;
33+
34+
$app->post('/oauth2/token', [
35+
BodyParamsMiddleware::class,
36+
OAuth2\TokenEndpointHandler::class
37+
], 'auth.token');
38+
```
39+
40+
WARNING: Do not pipe the body parsing middleware as generic middleware.
41+
This ensures that the content body is only parsed when it is actually expected.
42+
2443
## Add the authorization endpoint
2544

2645
The authorization endpoint is the URL to which the client redirects

0 commit comments

Comments
 (0)