奇怪的 HWIOAuthBundle 和 twig 错误“没有名称为“google”的资源所有者。”

问题描述 投票:0回答:2

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

在第 8 行的 HWIOAuthBundle:Connect:login.html.twig 中渲染模板期间抛出异常(“没有名称为“google”的资源所有者。”)。

甚至不清楚为什么它会抱怨“google”,而我们没有在任何地方引用它,而是现在连接了 facebook 连接。有遇到同样情况的吗

[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 endor\hwi\oauth-bundle\HWI\Bundle\OAuthBundle\Security\OAuthUtils.php 第 220 行

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
symfony twig hwioauthbundle
2个回答
8
投票

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

解决方案如下:

resource_owners:
下的按键,例如
resowner_key1:
必须在
config.yml
security.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

2
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.