From 2765481b9f0384fa1da68938369e3dcd84975d6a Mon Sep 17 00:00:00 2001 From: Andrew Millington Date: Sat, 18 Nov 2017 18:47:38 +0000 Subject: [PATCH] Handle no scope hint --- src/Exception/OAuthServerException.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Exception/OAuthServerException.php b/src/Exception/OAuthServerException.php index 45e03c07..8d101c4c 100644 --- a/src/Exception/OAuthServerException.php +++ b/src/Exception/OAuthServerException.php @@ -105,10 +105,15 @@ class OAuthServerException extends \Exception public static function invalidScope($scope, $redirectUri = null) { $errorMessage = 'The requested scope is invalid, unknown, or malformed'; - $hint = sprintf( - 'Check the `%s` scope', - htmlspecialchars($scope, ENT_QUOTES, 'UTF-8', false) - ); + + if (empty($scope)) { + $hint = 'Specify a scope in the request or set a default scope'; + } else { + $hint = sprintf( + 'Check the `%s` scope', + htmlspecialchars($scope, ENT_QUOTES, 'UTF-8', false) + ); + } return new static($errorMessage, 5, 'invalid_scope', 400, $hint, $redirectUri); }