I followed this gist https://gist.github.com/danvbe/4476697 to get HWIOauthBundle to work on my site, and now I can login fine via a LinkedIn account and persist the user to my local database, so I'm pretty happy with that. However, my next step is to retrieve more information about the user via the LinkedIn API, and for now I only have the username and the formatted-name fields.
I've looked around in the code, the interesting chunk of code is in OAuth/ResourceOwner/LinkedinResourceOwner.php:
protected $options = array(
'authorization_url' => 'https://www.linkedin.com/uas/oauth/authenticate',
'request_token_url' => 'https://api.linkedin.com/uas/oauth/requestToken',
'access_token_url' => 'https://api.linkedin.com/uas/oauth/accessToken',
'infos_url' => 'http://api.linkedin.com/v1/people/~:(id,formatted-name)',
'realm' => 'http://api.linkedin.com',
);
So i thought I only needed to overwrite this ResourceOwner and modify the line
'infos_url' => 'http://api.linkedin.com/v1/people/~:(id,formatted-name)',
by adding other fields. My idea was to create a MylinkedinResourceOwner class which extends the original LinkedinResourceOwner class. So that was what i did, and I added in my services.yml the following lines:
hwi_oauth.resource_owner.mylinkedin.class: Acme\UserBundle\OAuth\ResourceOwner\MylinkedinResourceOwner
hwi_oauth.abstract_resource_owner.mylinkedin:
class: "%hwi_oauth.resource_owner.mylinkedin.class%"
parent: hwi_oauth.abstract_resource_owner.oauth2
and of course changed in config.yml:
hwi_oauth:
resource_owners:
linkedin:
type: mylinkedin
client_id: ***
client_secret: ***
scope: r_fullprofile
But unfortunately I have the following error
InvalidConfigurationException: Invalid configuration for path "hwi_oauth.resource_owners.linkedin.type": Unknown resource owner type "mylinkedin".
So my question is: am I doing this right to get additional information of a LinkedIn account ? If so, how can I solve this error ?
Thanks !