2

此错误由 /login 路由中的 HWIOAuthBundle 触发:

在第 8 行的 HWIOAuthBundle:Connect:login.html.twig 中呈现模板(“没有名为 'google' 的资源所有者。”)时引发异常。

甚至不清楚为什么它抱怨“谷歌”,而我们没有在任何地方引用它,而是在连接一个 facbook 连接。有没有人遇到同样的情况?

[1] Twig_Error_Runtime: An exception has been thrown during the rendering of a template ("No resource owner with name 'google'.") in "HWIOAuthBundle:Connect:login.html.twig" at line 8.
at n/a
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4402

at Twig_Template->displayWithErrorHandling(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4372

at Twig_Template->display(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\twig\f3\c3\94f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e.php line 24

at __TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e->doDisplay(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4391

at Twig_Template->displayWithErrorHandling(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4372

at Twig_Template->display(array('error' => ''))
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4379

at Twig_Template->render(array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php line 53

at Symfony\Bridge\Twig\TwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php line 79

at Symfony\Bundle\TwigBundle\TwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine.php line 52

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php line 108

at Symfony\Bundle\TwigBundle\TwigEngine->renderResponse('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Controller\ConnectController.php line 71

at HWI\Bundle\OAuthBundle\Controller\ConnectController->connectAction(object(Request))
    in  line 

at call_user_func_array(array(object(ConnectController), 'connectAction'), array(object(Request)))
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2844

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2818

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2947

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2249

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in E:\Projects\my_project\Symfony\web\app.php line 23

[2] RuntimeException: 没有名为“google”的资源所有者。在 E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Security\OAuthUtils.php 第 220 行中的 n/a

at HWI\Bundle\OAuthBundle\Security\OAuthUtils->getResourceOwner('google')
    in E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Security\OAuthUtils.php line 114

at HWI\Bundle\OAuthBundle\Security\OAuthUtils->getLoginUrl(object(Request), 'google')
    in E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Templating\Helper\OAuthHelper.php line 69

at HWI\Bundle\OAuthBundle\Templating\Helper\OAuthHelper->getLoginUrl('google')
    in E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Twig\Extension\OAuthExtension.php line 63

at HWI\Bundle\OAuthBundle\Twig\Extension\OAuthExtension->getLoginUrl('google')
    in E:\Projects\my_project\Symfony\app\cache\prod\twig\f3\c3\94f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e.php line 46

at __TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e->block_hwi_oauth_content(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in  line 

at call_user_func(array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content'), array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4339

at Twig_Template->displayBlock('hwi_oauth_content', array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\twig\c5\58\f7730812ef8717461bfd2081b2ec682a7210fca6c5a4d0e2ce5a1de9cab2.php line 29

at __TwigTemplate_c558f7730812ef8717461bfd2081b2ec682a7210fca6c5a4d0e2ce5a1de9cab2->doDisplay(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4391

at Twig_Template->displayWithErrorHandling(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4372

at Twig_Template->display(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array('hwi_oauth_content' => array(object(__TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e), 'block_hwi_oauth_content')))
    in E:\Projects\my_project\Symfony\app\cache\prod\twig\f3\c3\94f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e.php line 24

at __TwigTemplate_f3c394f478b279ade4dd2d3ac458b9a9dd4ddb7db22da21707e88d9a5885896e->doDisplay(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4391

at Twig_Template->displayWithErrorHandling(array('error' => '', 'assetic' => array('debug' => true, 'vars' => object(ValueContainer), 'use_controller' => false), 'app' => object(GlobalVariables)), array())
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4372

at Twig_Template->display(array('error' => ''))
    in E:\Projects\my_project\Symfony\app\cache\prod\classes.php line 4379

at Twig_Template->render(array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bridge\Twig\TwigEngine.php line 53

at Symfony\Bridge\Twig\TwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php line 79

at Symfony\Bundle\TwigBundle\TwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine.php line 52

at Symfony\Bundle\TwigBundle\Debug\TimedTwigEngine->render('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\symfony\symfony\src\Symfony\Bundle\TwigBundle\TwigEngine.php line 108

at Symfony\Bundle\TwigBundle\TwigEngine->renderResponse('HWIOAuthBundle:Connect:login.html.twig', array('error' => ''))
    in E:\Projects\my_project\Symfony\vendor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Controller\ConnectController.php line 71

at HWI\Bundle\OAuthBundle\Controller\ConnectController->connectAction(object(Request))
    in  line 

at call_user_func_array(array(object(ConnectController), 'connectAction'), array(object(Request)))
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2844

at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2818

at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2947

at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
    in E:\Projects\my_project\Symfony\app\bootstrap.php.cache line 2249

at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
    in E:\Projects\my_project\Symfony\web\app.php line 23
4

2 回答 2

8

如果您想正确配置 oauth,上述接受的解决方案将不起作用。

这是解决方案:

resource_owners:eg下的键必须在下面的文件resowner_key1:中都匹配。config.ymlsecurity.yml

在你的config.yml文件中

hwi_oauth:
    # name of the firewall in which this bundle is active, this setting MUST be set
    firewall_name: open_auth

    resource_owners:
        resowner_key1:
            type:                facebook #e.g. facebook, google
            client_id:           <client_id>
            client_secret:       <secret_id>
            options:
                display: popup #dialog is optimized for popup window

而在security.yml

open_auth:
    anonymous: ~
    oauth:
        resource_owners:
            resowner_key1:           "/login/check-facebook"
        login_path:        /login
        use_forward:       false
        failure_path:      /login

        oauth_user_provider:
            service: fos_user_provider
于 2014-09-30T17:41:01.407 回答
2

检查您的安全配置文件 (app/config/security.yml) 并从 resource_owners 部分下删除“google”

于 2013-10-22T07:23:03.240 回答