0

ドキュメントに苦労した後、ここの例に従って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

ルーティング.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
    }
}

エラー:

警告: /opt/lampp/htdocs/workoutexchange/trunk/WorkoutExchange/vendor/hwi/oauth-bundle/HWI/Bundle/OAuthBundle/OAuth/ で呼び出される WX\ExchangeBundle\Service\OAuthUserProvider::__construct() の引数 1 がありません186 行目の ResourceOwner/AbstractResourceOwner.php および 13 行目の /opt/lampp/htdocs/workoutexchange/trunk/WorkoutExchange/src/WX/ExchangeBundle/Service/OAuthUserProvider.php で定義されています

4

2 に答える 2

0

私はこのエラーに長い間苦労していました。

providers:
--->>>my_custom_hwi_provider:
---->>>>>>> id: wxexchange_oauth_user_provider

この 2 行をコメントにします。ファイアウォール セクションでサービスを宣言します。プロバイダーとして宣言する必要はありません。

この後、あなたの問題は解決されます...

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
于 2015-02-05T20:09:15.633 に答える