您好我正在使用这个优秀的PHP库来创建我自己的Oauth2服务器,所以我试图将一些默认范围设置为授权请求,但我收到此错误,我正在寻找一个大约3天前的解决方案。
Fatal error: Uncaught exception 'BadMethodCallException' with message 'Method Mockery_0_Dingo_OAuth2_Storage_ScopeInterface::get() does not exist on this mock object'
这是我的PHP代码:
$server = new Dingo\OAuth2\Server\Authorization($storage);
$server->registerGrant(new Dingo\OAuth2\Grant\AuthorizationCode);
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$validator = new Dingo\OAuth2\ScopeValidator($request, Mockery::mock('Dingo\OAuth2\Storage\ScopeInterface'));
$validator->setDefaultScope(['accounts.profile.basic']);
$validator->requireScope();
$validator->validate(); // This line is what causes the error
$server->setScopeValidator($validator);
$payload = $server->validateAuthorizationRequest();
Github Dingo Oauth2-server:https://github.com/dingo/oauth2-server
答案 0 :(得分:0)
我使用以下方法解决了这个问题:$storage->createScopeStorage()
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
$validator = new Dingo\OAuth2\ScopeValidator($request, $storage->createScopeStorage());
$validator->setDefaultScope(['accounts.profile.basic']);
$validator->requireScope();
$server->setScopeValidator($validator);
$payload = $server->validateAuthorizationRequest();