Symfony2 - HWIOAuthBundle - Facebook 登录
Symfony2 - HWIOAuthBundle - Facebook login
我遵循了 bundle documentation configuring the HWIOAuthBundle
for facebook. Then I followed this facebook 登录按钮显示的示例,它似乎可以正常工作,但尚未完成。我被困住了,不知道下一步该怎么做。在我按下 facebook 登录按钮并登录到 facebook 后,我收到错误消息:
Unable to find the controller for path "/sign-in/check-facebook". The route is wrongly configured.
config.yml
hwi_oauth:
firewall_name: hwi_oauth
resource_owners:
facebook:
type: facebook
client_id: "%facebook_client_id%"
client_secret: "%facebook_client_secret%"
scope: email
options:
display: popup
auth_type: rerequest
csrf: true
security.yml
firewalls:
hwi_oauth:
pattern: ^/
anonymous: ~
oauth:
resource_owners:
facebook: /sign-in/check-facebook
login_path: /sign-in
failure_path: /sign-in
oauth_user_provider:
service: oauth_user_provider
routing.yml
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /sign-in
facebook_login:
path: /sign-in/check-facebook
那么这个 /sign-in/check-facebook
有什么用呢?为什么我的应用程序找不到它?我必须为它创建控制器吗?
文档here中说可以通过response对象获取信息,但是这个代码写在哪里呢?
看看你的security.yml
。在您的 hwi_oauth
防火墙之前,您是否有应用程序可能正在处理的任何其他防火墙? @jkuri 似乎在这里遇到了这个问题:https://github.com/hwi/HWIOAuthBundle/issues/781#issuecomment-100468744
他的回答:
To answer my own question... a added firewall olta_portal before main firewall... don't know where was the problem, maybe because of the same pattern ^/ in both firewalls. Working now.
我以前也遇到过这个问题!另一项健全性检查是执行 php app/console debug:router | grep facebook
,以验证您的路由是否已在第一时间注册到应用程序。
我在配置 HWIOAuthBundle 时遇到了很多困难,所以当我最终正确配置时,我通过将它添加到 pretty nice tutorial:
中来确保我永远不会忘记它
firewalls:
main:
pattern: ^/
oauth:
failure_path: your_path
login_path: your_path
check_path: /connect_check
provider: fos_userbundle
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
oauth_user_provider:
service: app.provider.oauth
教程还解释了如何正确设置 FOSUBUserProvider
、UserModel
以及如何添加链接。
我遵循了 bundle documentation configuring the HWIOAuthBundle
for facebook. Then I followed this facebook 登录按钮显示的示例,它似乎可以正常工作,但尚未完成。我被困住了,不知道下一步该怎么做。在我按下 facebook 登录按钮并登录到 facebook 后,我收到错误消息:
Unable to find the controller for path "/sign-in/check-facebook". The route is wrongly configured.
config.yml
hwi_oauth:
firewall_name: hwi_oauth
resource_owners:
facebook:
type: facebook
client_id: "%facebook_client_id%"
client_secret: "%facebook_client_secret%"
scope: email
options:
display: popup
auth_type: rerequest
csrf: true
security.yml
firewalls:
hwi_oauth:
pattern: ^/
anonymous: ~
oauth:
resource_owners:
facebook: /sign-in/check-facebook
login_path: /sign-in
failure_path: /sign-in
oauth_user_provider:
service: oauth_user_provider
routing.yml
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /connect
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /sign-in
facebook_login:
path: /sign-in/check-facebook
那么这个 /sign-in/check-facebook
有什么用呢?为什么我的应用程序找不到它?我必须为它创建控制器吗?
文档here中说可以通过response对象获取信息,但是这个代码写在哪里呢?
看看你的security.yml
。在您的 hwi_oauth
防火墙之前,您是否有应用程序可能正在处理的任何其他防火墙? @jkuri 似乎在这里遇到了这个问题:https://github.com/hwi/HWIOAuthBundle/issues/781#issuecomment-100468744
他的回答:
To answer my own question... a added firewall olta_portal before main firewall... don't know where was the problem, maybe because of the same pattern ^/ in both firewalls. Working now.
我以前也遇到过这个问题!另一项健全性检查是执行 php app/console debug:router | grep facebook
,以验证您的路由是否已在第一时间注册到应用程序。
我在配置 HWIOAuthBundle 时遇到了很多困难,所以当我最终正确配置时,我通过将它添加到 pretty nice tutorial:
中来确保我永远不会忘记它firewalls:
main:
pattern: ^/
oauth:
failure_path: your_path
login_path: your_path
check_path: /connect_check
provider: fos_userbundle
resource_owners:
facebook: "/login/check-facebook"
google: "/login/check-google"
oauth_user_provider:
service: app.provider.oauth
教程还解释了如何正确设置 FOSUBUserProvider
、UserModel
以及如何添加链接。