2018-04-28 10:28:53 2241次浏览 2条回答 0 悬赏 10 金钱

用composer安装完oauth2.0,其他的都按照步骤配置好了。测试token的时候报错

{
    "name": "PHP Recoverable Error",
    "message": "Argument 1 passed to OAuth2\\Server::handleTokenRequest() must be an instance of OAuth2\\RequestInterface, instance of yii\\web\\Request given, called in C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\filsh\\yii2-oauth2-server\\Server.php on line 39 and defined",
    "code": 4096,
    "type": "yii\\base\\ErrorException",
    "file": "C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\bshaffer\\oauth2-server-php\\src\\OAuth2\\Server.php",
    "line": 316,
    "stack-trace": [
        "#0 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\bshaffer\\oauth2-server-php\\src\\OAuth2\\Server.php(316): yii\\base\\ErrorHandler->handleError(4096, 'Argument 1 pass...', 'C:\\\\phpStudy\\\\PHP...', 316, Array)",
        "#1 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\filsh\\yii2-oauth2-server\\Server.php(39): OAuth2\\Server->handleTokenRequest(Object(yii\\web\\Request), NULL)",
        "#2 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\filsh\\yii2-oauth2-server\\controllers\\RestController.php(25): filsh\\yii2\\oauth2server\\Server->handleTokenRequest()",
        "#3 [internal function]: filsh\\yii2\\oauth2server\\controllers\\RestController->actionToken()",
        "#4 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\yiisoft\\yii2\\base\\InlineAction.php(57): call_user_func_array(Array, Array)",
        "#5 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\yiisoft\\yii2\\base\\Controller.php(157): yii\\base\\InlineAction->runWithParams(Array)",
        "#6 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\yiisoft\\yii2\\base\\Module.php(528): yii\\base\\Controller->runAction('token', Array)",
        "#7 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\yiisoft\\yii2\\web\\Application.php(103): yii\\base\\Module->runAction('oauth2/rest/tok...', Array)",
        "#8 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\vendor\\yiisoft\\yii2\\base\\Application.php(386): yii\\web\\Application->handleRequest(Object(yii\\web\\Request))",
        "#9 C:\\phpStudy\\PHPTutorial\\WWW\\oauthtest\\api\\web\\index.php(17): yii\\base\\Application->run()",
        "#10 {main}"
    ]
}
补充于 2018-04-28 10:33
  • 回答于 2018-06-13 08:55 举报

    问题解决了么

  • 回答于 2018-06-13 14:43 举报
    public function getRequest()
        {
            if(!ArrayHelper::keyExists('request', $this->getComponents())) {
                $this->set('request', Request::createFromGlobals());
            }
            return $this->get('request');
        }
        
        public function getResponse()
        {
            if(!ArrayHelper::keyExists('response', $this->getComponents())) {
                $this->set('response', new Response());
            }
            return $this->get('response');
        }
    

    修改filsh\yii2\oauth2server\Module

您需要登录后才可以回答。登录 | 立即注册
wjj891201
实习生

wjj891201

注册时间:2018-04-28
最后登录:2019-05-07
在线时长:0小时44分
  • 粉丝0
  • 金钱10
  • 威望0
  • 积分10

热门问题