Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Exception/OAuthServerException.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public static function invalidScope($scope, $redirectUri = null)
*/
public static function invalidCredentials()
{
return new static('The user credentials were incorrect.', 6, 'invalid_credentials', 401);
return new static('The user credentials were incorrect.', 6, 'invalid_grant', 400);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Grant/PasswordGrant.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function validateUser(ServerRequestInterface $request, ClientEntityInt
if ($user instanceof UserEntityInterface === false) {
$this->getEmitter()->emit(new RequestEvent(RequestEvent::USER_AUTHENTICATION_FAILED, $request));

throw OAuthServerException::invalidGrant();
throw OAuthServerException::invalidCredentials();
}

return $user;
Expand Down
7 changes: 7 additions & 0 deletions tests/Exception/OAuthServerExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,11 @@ public function testCanGetRedirectionUri()

$this->assertSame('https://example.com/error', $exceptionWithRedirect->getRedirectUri());
}

public function testInvalidCredentialsIsInvalidGrant()
{
$exception = OAuthServerException::invalidCredentials();

$this->assertSame('invalid_grant', $exception->getErrorType());
}
}
2 changes: 1 addition & 1 deletion tests/Grant/PasswordGrantTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function testRespondToRequestBadCredentials()
$responseType = new StubResponseType();

$this->expectException(\League\OAuth2\Server\Exception\OAuthServerException::class);
$this->expectExceptionCode(10);
$this->expectExceptionCode(6);

$grant->respondToAccessTokenRequest($serverRequest, $responseType, new DateInterval('PT5M'));
}
Expand Down