mirror of
https://github.com/elyby/oauth2-server.git
synced 2025-01-05 11:41:53 +05:30
Updated exception reference
This commit is contained in:
parent
32b451aa21
commit
c0bdd22154
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use League\OAuth2\Server\Exception\OAuthException;
|
use League\OAuth2\Server\Exception\OAuthServerException;
|
||||||
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
use League\OAuth2\Server\Grant\ClientCredentialsGrant;
|
||||||
use League\OAuth2\Server\Server;
|
use League\OAuth2\Server\Server;
|
||||||
|
|
||||||
@ -27,14 +27,13 @@ $server->enableGrantType(new ClientCredentialsGrant($clientRepository, $scopeRep
|
|||||||
|
|
||||||
// App
|
// App
|
||||||
$app = new App([Server::class => $server]);
|
$app = new App([Server::class => $server]);
|
||||||
unset($app->getContainer()['errorHandler']);
|
|
||||||
|
|
||||||
$app->post('/access_token', function (Request $request, Response $response) {
|
$app->post('/access_token', function (Request $request, Response $response) {
|
||||||
/** @var Server $server */
|
/** @var Server $server */
|
||||||
$server = $this->getContainer()->get(Server::class);
|
$server = $this->getContainer()->get(Server::class);
|
||||||
try {
|
try {
|
||||||
return $server->respondToRequest($request);
|
return $server->respondToRequest($request);
|
||||||
} catch (OAuthException $e) {
|
} catch (OAuthServerException $e) {
|
||||||
return $e->generateHttpResponse();
|
return $e->generateHttpResponse();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return $response->withStatus(500)->write($e->getMessage());
|
return $response->withStatus(500)->write($e->getMessage());
|
||||||
|
Loading…
Reference in New Issue
Block a user