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