#[Route(path: '/api/oauth/token', name: 'api.oauth.token', defaults: ['auth_required' => false], methods: ['POST'])]
public function token(Request
$request): Response
{ $response =
new Response();
try { $cacheKey =
$request->
get('username'
) . '-' .
$request->
getClientIp();
$this->rateLimiter->
ensureAccepted(RateLimiter::OAUTH,
$cacheKey);
} catch (RateLimitExceededException
$exception) { throw new AuthThrottledException($exception->
getWaitTime(),
$exception);
} $psr7Request =
$this->psrHttpFactory->
createRequest($request);
$psr7Response =
$this->psrHttpFactory->
createResponse($response);
$response =
$this->authorizationServer->
respondToAccessTokenRequest($psr7Request,
$psr7Response);
$this->rateLimiter->
reset(RateLimiter::OAUTH,
$cacheKey);
return (new HttpFoundationFactory())->
createResponse($response);
}}