diff --git a/examples/public/client_credentials.php b/examples/public/client_credentials.php index 1792eb69..c1ca45f0 100644 --- a/examples/public/client_credentials.php +++ b/examples/public/client_credentials.php @@ -50,7 +50,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI $server = $app->getContainer()->get(Server::class); try { - return $server->respondToRequest($request, $response); + return $server->respondToAccessTokenRequest($request, $response); } catch (OAuthServerException $exception) { return $exception->generateHttpResponse($response); } catch (\Exception $exception) { diff --git a/examples/public/password.php b/examples/public/password.php index c04c0e91..d8145050 100644 --- a/examples/public/password.php +++ b/examples/public/password.php @@ -54,7 +54,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI $server = $app->getContainer()->get(Server::class); try { - return $server->respondToRequest($request, $response); + return $server->respondToAccessTokenRequest($request, $response); } catch (OAuthServerException $exception) { return $exception->generateHttpResponse($response); } catch (\Exception $exception) { diff --git a/examples/public/refresh_token.php b/examples/public/refresh_token.php index 64553311..c8c0a396 100644 --- a/examples/public/refresh_token.php +++ b/examples/public/refresh_token.php @@ -52,7 +52,7 @@ $app->post('/access_token', function (ServerRequestInterface $request, ResponseI $server = $app->getContainer()->get(Server::class); try { - return $server->respondToRequest($request, $response); + return $server->respondToAccessTokenRequest($request, $response); } catch (OAuthServerException $exception) { return $exception->generateHttpResponse($response); } catch (\Exception $exception) { diff --git a/src/Server.php b/src/Server.php index e5573026..3513d642 100644 --- a/src/Server.php +++ b/src/Server.php @@ -134,7 +134,7 @@ class Server implements EmitterAwareInterface * * @return \Psr\Http\Message\ResponseInterface */ - public function respondToRequest(ServerRequestInterface $request, ResponseInterface $response) + public function respondToAccessTokenRequest(ServerRequestInterface $request, ResponseInterface $response) { $tokenResponse = null; while ($tokenResponse === null && $grantType = array_shift($this->enabledGrantTypes)) { diff --git a/tests/ServerTest.php b/tests/ServerTest.php index 68dae3b1..82d07059 100644 --- a/tests/ServerTest.php +++ b/tests/ServerTest.php @@ -38,7 +38,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase $server->enableGrantType(new ClientCredentialsGrant(), new \DateInterval('PT1M')); try { - $server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response); + $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response); } catch (OAuthServerException $e) { $this->assertEquals('unsupported_grant_type', $e->getErrorType()); $this->assertEquals(400, $e->getHttpStatusCode()); @@ -70,7 +70,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase $_POST['grant_type'] = 'client_credentials'; $_POST['client_id'] = 'foo'; $_POST['client_secret'] = 'bar'; - $response = $server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response); + $response = $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response); $this->assertEquals(200, $response->getStatusCode()); } @@ -119,7 +119,7 @@ class ServerTest extends \PHPUnit_Framework_TestCase $_POST['action'] = 'approve'; $_POST['username'] = 'user'; $_POST['password'] = 'pass'; - $response = $server->respondToRequest(ServerRequestFactory::fromGlobals(), new Response); + $response = $server->respondToAccessTokenRequest(ServerRequestFactory::fromGlobals(), new Response); $this->assertTrue($response instanceof ResponseInterface); $this->assertEquals(302, $response->getStatusCode()); $this->assertTrue(strstr($response->getHeaderLine('location'), 'code=') !== false);