function checkScope receives array of string as the second parameter but it expects a string
Hi @bshaffer,
When executing the following curl command to test the token endpoint:
curl -u testuser:testpass https://someIP/Symfony-OAuth-Server/web/app_dev.php/token -k -d 'grant_type=client_credentials&scope=photo_engine'
the following error is given:
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Scope.php line 49
at Symfony\Component\Debug\ErrorHandler->handle('2', 'trim() expects parameter 1 to be string, array given', '/var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Scope.php', '49', array('required_scope' => array('photo_engine'), 'available_scope' => array('xyz', 'photo_engine')))
in line
at trim(array('xyz', 'photo_engine'))
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Scope.php line 49
at OAuth2\Scope->checkScope('photo_engine', array('xyz', 'photo_engine'))
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Controller/TokenController.php line 173
at OAuth2\Controller\TokenController->grantAccessToken(object(Request), object(Response))
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Controller/TokenController.php line 49
at OAuth2\Controller\TokenController->handleTokenRequest(object(Request), object(Response))
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-php/src/OAuth2/Server.php line 256
at OAuth2\Server->handleTokenRequest(object(Request), object(Response))
in /var/www/Symfony-OAuth-Server/vendor/bshaffer/oauth2-server-bundle/OAuth2/ServerBundle/Controller/TokenController.php line 31
What happens is that the function checkScope gets an array of available scopes as the second parameter and tries to trim it. Either the function checkScope should get string as the second parameter or it should not be trimmed because array is already provided.
This kind of behaviour comes out of the box.
@SaniGit You can fix this by upgrading to dev-develop, or by waiting for the next tagged release of v0.3, which I will add later today
This was fixed here back in August: https://github.com/bshaffer/oauth2-server-bundle/commit/8032b1c1dcf281775cd481d0d4c305a119e9c74e