cirrusidentity / simplesamlphp-module-authoauth2

OAuth2/OIDC Authentication module for SimpleSAMLphp
GNU Lesser General Public License v2.1
31 stars 28 forks source link

Linkedin v2 Api #18

Open umardraz opened 5 years ago

umardraz commented 5 years ago

Hi

'linkedin' => array(
        'authoauth2:LinkedInV2Auth',
        'clientId' => '2KodETR7hsnp80al',
        'clientSecret' => 'ADFlKzKmk3UacdfTYU',
        'scopes' => ['r_liteprofile', 'r_emailaddress']
)

The above is my authsource.php settings for linkedin authentication, it working fine but only giving me these attributes

linkedin.id, linkedin.firstName, linkedin.lastName and linkedin.emailAddress

Would you please tell me how I can get

linkedin.location.name, linkedin.publicProfileUrl, and linkedin.pictureUrl

pradtke commented 5 years ago

I think you'll need to review the LinkedIn documentation to determine what the correct scope is to use (r_liteprofile or r_basicprofile) and then adjust the scopes you configure for the module . You'll also need to set urlResourceOwnerOptions to the query params that LinkedIn expects to request the attributes you want. urlResourceOwnerOptions is an array of queryParam => value. If you need to make additional API calls to LinkedIn then you can subclass LinkedInV2Auth and override the postFinalStep method to make additional API calls with the access token.

umardraz commented 5 years ago

Hi

Already had this in ConfigTemplate.php

urlResourceOwnerDetails' => 'https://api.linkedin.com/v2/me?projection=(id,firstName,lastName,profilePicture(displayImage~:playableStreams))',

I think ProfileAttribue is missing in thiis authoauth2 plugin so I had modified LinkedinV2Auth.php and added this code

 $attributes = [
            $prefix . "id" => [$resourceOwnerAttributes["id"]],
            $prefix . "pictureUrl" => [$resourceOwnerAttributes["profilePicture"]['displayImage~']['elements'][0]['identifiers'][0]['identifier']]
        ];

Don't know this is the correct way or not.