/** * Return an access token response. * * @param ServerRequestInterface $request * @param ResponseInterface $response * * @throws OAuthServerException * * @return ResponseInterface */ public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) { foreach ($this->enabledGrantTypes as $grantType) { if ($grantType->canRespondToAccessTokenRequest($request)) { $tokenResponse = $grantType->respondToAccessTokenRequest($request, $this->getResponseType(), $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]); if ($tokenResponse instanceof ResponseTypeInterface) { return $tokenResponse->generateHttpResponse($response); } } } throw OAuthServerException::unsupportedGrantType(); }
/** * Return an access token response. * * @param \Phalcon\Http\RequestInterface $request * @param \Ivyhjk\OAuth2\Server\Contract\Http\Response $response * * @throws \League\OAuth2\Server\Exception\OAuthServerException * * @return \Ivyhjk\OAuth2\Server\Contract\Http\Response **/ public function respondToAccessTokenRequest(RequestContract $request, ResponseContract $response) { $tokenResponse = null; while ($tokenResponse === null && ($grantType = array_shift($this->enabledGrantTypes))) { /** @var \League\OAuth2\Server\Grant\GrantTypeInterface $grantType */ if ($grantType->canRespondToAccessTokenRequest($request)) { $tokenResponse = $grantType->respondToAccessTokenRequest($request, $this->getResponseType(), $this->grantTypeAccessTokenTTL[$grantType->getIdentifier()]); } } if ($tokenResponse instanceof ResponseTypeContract) { return $tokenResponse->generateHttpResponse($response); } throw OAuthServerException::unsupportedGrantType(); }