我在示例here之后添加了HWIOAuthBundle。我被重定向到Google很好但是当它返回时我得到一个警告,第一个参数丢失了。
config.yml
services:
wxexchange_oauth_user_provider:
class: WX\ExchangeBundle\Service\OAuthUserProvider
arguments: [@session, @doctrine, @service_container]
hwi_oauth:
resource_owners:
google:
type: google
client_id: xxxxxx
client_secret: xxxxx
scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
user_response_class: \WX\ExchangeBundle\Service\OAuthUserProvider
firewall_name: main
security.yml
providers:
my_custom_hwi_provider:
id: wxexchange_oauth_user_provider
firewalls:
main:
pattern: ^/
anonymous: ~
provider: main
form_login:
check_path: login_check
login_path: /Login
csrf_provider: form.csrf_provider
logout:
path: logout
oauth:
resource_owners:
facebook: "/Login/OAuth/check-facebook"
google: "/Login/OAuth/check-google"
login_path: /Login/OAuth
use_forward: false
failure_path: /Login
oauth_user_provider:
service: wxexchange_oauth_user_provider
的routing.yml
hwi_oauth_login:
resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
prefix: /Login/OAuth
hwi_oauth_connect:
resource: "@HWIOAuthBundle/Resources/config/routing/connect.xml"
prefix: /Login/OAuth
hwi_oauth_redirect:
resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
prefix: /Login/OAuth
google_login:
pattern: /Login/OAuth/check-google
facebook_login:
pattern: /Login/OAuth/check-facebook
OAuthUserProvider.php
class OAuthUserProvider extends BaseOAuthUserProvider
{
protected $session, $doctrine, $admins;
public function __construct($session, $doctrine, $service_container)
{
$this->session = $session;
$this->doctrine = $doctrine;
$this->container = $service_container;
}
public function loadUserByUsername($username)
{
//code
}
public function loadUserByOAuthUserResponse(UserResponseInterface $response)
{
//code
}
}
错误:
警告:缺少参数1 调用了WX \ ExchangeBundle \ Service \ OAuthUserProvider :: __ construct() /opt/lampp/htdocs/workoutexchange/trunk/WorkoutExchange/vendor/hwi/oauth-bundle/HWI/Bundle/OAuthBundle/OAuth/ResourceOwner/AbstractResourceOwner.php 在第186行并在中定义 /opt/lampp/htdocs/workoutexchange/trunk/WorkoutExchange/src/WX/ExchangeBundle/Service/OAuthUserProvider.php 第13行
答案 0 :(得分:0)
services:
config.yml
部分中的这一行是错误的:
user_response_class: \WX\ExchangeBundle\Service\OAuthUserProvider
见the configuration reference here。我不确定它需要什么(Google Oauth example没有提到它),但我认为它应该是一个简单的价值对象,而不是你的用户提供者。
答案 1 :(得分:0)
我很久以来一直在努力解决这个错误。
providers:
--->>>my_custom_hwi_provider:
---->>>>>>> id: wxexchange_oauth_user_provider
评论这两行。您在防火墙部分声明了该服务。您不必将其声明为提供者。
在此之后你的问题将会解决......
firewalls:
........
oauth:
resource_owners:
facebook: "/Login/OAuth/check-facebook"
google: "/Login/OAuth/check-google"
login_path: /Login/OAuth
use_forward: false
failure_path: /Login
oauth_user_provider:
service: wxexchange_oauth_user_provider