diff --git a/src/OAuth2/AuthServer.php b/src/OAuth2/AuthServer.php index 2d72bdd5..3c3dc008 100644 --- a/src/OAuth2/AuthServer.php +++ b/src/OAuth2/AuthServer.php @@ -63,6 +63,12 @@ class AuthServer */ protected $requireScopeParam = true; + /** + * Default scope to be used if none is provided and requireScopeParam is false + * @var string + */ + protected $defaultScope = null; + /** * Require the "state" parameter to be in checkAuthoriseParams() * @var boolean @@ -186,6 +192,15 @@ class AuthServer $this->requireScopeParam = $require; } + /** + * Default scope to be used if none is provided and requireScopeParam is false + * @var string + */ + public function defaultScope($default = null) + { + $this->defaultScope = $default; + } + /** * Require the "state" paremter in checkAuthoriseParams() * @param boolean $require @@ -323,6 +338,8 @@ class AuthServer if ($this->requireScopeParam === true && count($scopes) === 0) { throw new Exception\ClientException(sprintf(self::$exceptionMessages['invalid_request'], 'scope'), 0); + } elseif (count($scopes) === 0 && $this->defaultScope) { + $scopes = array($this->defaultScope); } $authParams['scopes'] = array();