enableGrantType(new ClientCredentialsGrant($clientRepository, $scopeRepository, $accessTokenRepository)); // App $app = new App([Server::class => $server]); unset($app->getContainer()['errorHandler']); $app->post('/access_token', function (Request $request, Response $response) { /** @var Server $server */ $server = $this->getContainer()->get(Server::class); try { return $server->respondToRequest($request); } catch (OAuthException $e) { return $e->generateHttpResponse(); } catch (\Exception $e) { return $response->withStatus(500)->write($e->getMessage()); } }); $app->run();