user4685464
user4685464

Reputation:

hwioauthbundle configure for google

i try configure this bundle for authication with google api. I see documentation and search in google, but still can't configure.

Now i have this error :

The service "hwi_oauth.security.oauth_utils" has a dependency on a non-existent service "hwi_oauth.resource_ownermap.main".

Now i only want show in my default page link for google and when i click for it, i want get response from google and show it in var dump..

routing.yml:

hwi_oauth_redirect:
    resource: "@HWIOAuthBundle/Resources/config/routing/redirect.xml"
    prefix:   /login

hwi_oauth_login:
    resource: "@HWIOAuthBundle/Resources/config/routing/login.xml"
    prefix:   /login

google_login:
    path: /login/check-google

config.yml

hwi_oauth:
    connect:
        account_connector: defaultbundle.oauth_provider
    firewall_names: [secured_area]

    resource_owners:
        google:
            type:                google
            client_id:           ****
            client_secret:       ****
            scope:               "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"

security.yml

    secured_area:
        pattern: ^/
        anonymous: ~
        oauth:
            resource_owners:
                google:             "/login/check-google"
            login_path:        /login
            use_forward:       false
            failure_path:      /login

            oauth_provider:
                service: defaultbundle.oauth_provider
        logout:       true
        anonymous:    true
#        access_control:
#            - { path: ^/login, roles: IS_AUTHENTICATED_ANONYMOUSLY }

services.yml

    defaultbundle.oauth_provider:
    class: Public\defaultBundle\Auth\OAuthProvider
    arguments: [@doctrine]

base.html

 <a href="{{ path('hwi_oauth_service_redirect', {'service': 'google' }) }}">
                                <span>Google</span>
                            </a>

OAuthProvider.php

    use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthUserProvider;
use HWI\Bundle\OAuthBundle\OAuth\Response\UserResponseInterface;
use HWI\Bundle\OAuthBundle\Security\Core\User\OAuthAwareUserProviderInterface;

class OAuthProvider extends OAuthUserProvider
{



}

Upvotes: 1

Views: 1908

Answers (1)

Fracsi
Fracsi

Reputation: 2314

The firewall name in hwi_oauth configuration in config.yml (currently: main) is wrong. It must match the firewall name(s) from the security.yml (currently: secured_area) that uses ouath.

hwi_ouath:
    connect:
        account_connector: defaultbundle.oauth_provider
    firewall_name: secured_area # <---- here is the change (if using 0.3)
    firewall_names: [secured_area] # <--- if using 0.4
    ...

Documentation:

Upvotes: 2

Related Questions