auth0 / passport-linkedin-oauth2

Passport Strategy for LinkedIn OAuth 2.0
MIT License
119 stars 106 forks source link

Add all pictures in profile photos #41

Closed JSteunou closed 7 years ago

JSteunou commented 8 years ago

linkedin also return pictureUrls which is like

  "pictureUrls": {
    "_total": 1,
    "values": ["https://media.licdn.com/mpr/mprx/0_PQwK..."]
  }

could be used in profile photos attribute.

oieesah commented 8 years ago

@JSteunou *\ I will remove this comment.

I am only getting "pictureUrl" in response and not "pictureUrls" or "picture-urls::(original)". Any idea how i can get the full image?

siacomuzzi commented 8 years ago

Hi @oieesah, please check the following:

  1. You are using passport-linkedin-oauth2@1.4.x
  2. Linkedin Developer Portal -> My Apps -> {YOUR_APP_NAME} -> Default Application Permissions: Enable r_basicprofile
  3. LinkedInStrategy settings: make sure to include scope: [ 'r_basicprofile' ]

Then pictureUrls should be available in profile._json object.

oieesah commented 8 years ago

@siacomuzzi I have verified both of these points.

The response i am getting is this:

{ emailAddress: 'haseebkhilji@gmail.com', firstName: 'Haseeb', headline: 'Student', id: 'pTTFC8Wm7-', industry: 'Computer Software', lastName: 'Ahmad', location: { country: [Object], name: 'Pakistan' }, pictureUrl: 'https://media.licdn.com/mpr/mprx/0_ORAOgKuovqDjSz0_AEbKVN9oPqYjHN0-cRWOZkion5-yHXY-U05xnC3oK5GjH5-0UDd11kCEs_fpwrBY-eqGvkfQ0_fgwrV0BeqjY5VwqCVAT63_RJCPOAqsx9zSGrSaOIK-JURSaxs', publicProfileUrl: 'https://www.linkedin.com/in/haseeb-ahmad-52b11455' }

You can see, not pictureUrls.

siacomuzzi commented 8 years ago

Check profile._json object (https://github.com/auth0/passport-linkedin-oauth2/blob/master/lib/oauth2.js#L48-L50)

oieesah commented 8 years ago

Yes i did.

Following is the complete "profile" object (including ._json):

{ provider: 'linkedin', id: 'pTTFC8Wm7-', displayName: 'Haseeb Ahmad', name: { familyName: 'Ahmad', givenName: 'Haseeb' }, emails: [ { value: 'haseebkhilji@gmail.com' } ], _raw: '{\n "emailAddress": "haseebkhilji@gmail.com",\n "firstName": "Haseeb",\n "headline": "Student",\n "id": "pTTFC8Wm7-",\n "industry": "Computer Software",\n "lastName": "Ahmad",\n "location": {\n "country": {"code": "pk"},\n "name": "Pakistan"\n },\n "pictureUrl": "https://media.licdn.com/mpr/mprx/0_ORAOgKuovqDjSz0_AEbKVN9oPqYjHN0-cRWOZkion5-yHXY-U05xnC3oK5GjH5-0UDd11kCEs_fpwrBY-eqGvkfQ0_fgwrV0BeqjY5VwqCVAT63_RJCPOAqsx9zSGrSaOIK-JURSaxs",\n "publicProfileUrl": "https://www.linkedin.com/in/haseeb-ahmad-52b11455"\n}', _json: { emailAddress: 'haseebkhilji@gmail.com', firstName: 'Haseeb', headline: 'Student', id: 'pTTFC8Wm7-', industry: 'Computer Software', lastName: 'Ahmad', location: { country: [Object], name: 'Pakistan' }, pictureUrl: 'https://media.licdn.com/mpr/mprx/0_ORAOgKuovqDjSz0_AEbKVN9oPqYjHN0-cRWOZkion5-yHXY-U05xnC3oK5GjH5-0UDd11kCEs_fpwrBY-eqGvkfQ0_fgwrV0BeqjY5VwqCVAT63_RJCPOAqsx9zSGrSaOIK-JURSaxs', publicProfileUrl: 'https://www.linkedin.com/in/haseeb-ahmad-52b11455' } }

siacomuzzi commented 8 years ago

you are using passport-linkedin-oauth2@1.4.x, right?

please put a console.log(this.profileUrl) here: https://github.com/auth0/passport-linkedin-oauth2/blob/master/lib/oauth2.js#L19 and show us the output.

oieesah commented 8 years ago

I have copied this response from console. Yes i have download this module today. To be more specific, i am using "passport-linkedin-oauth2": "~1.4.1"

siacomuzzi commented 8 years ago

please put a console.log(this.profileUrl) here: https://github.com/auth0/passport-linkedin-oauth2/blob/master/lib/oauth2.js#L19 and show us the output.

oieesah commented 8 years ago

@siacomuzzi Here it is:

https://api.linkedin.com/v1/people/~:(email-address,id,first-name,last-name,picture-url,picture-urls::(original),formatted-name,maiden-name,phonetic-first-name,phonetic-last-name,formatted-phonetic-name,headline,location:(name,country:(code)),industry,distance,relation-to-viewer:(distance,connections),current-share,num-connections,num-connections-capped,summary,specialties,positions,site-standard-profile-request,api-standard-profile-request:(headers,url),public-profile-url)

siacomuzzi commented 8 years ago

looks good.

could you please try with another linkedin user?

oieesah commented 8 years ago

@siacomuzzi Good point, Sure.

oieesah commented 8 years ago

@siacomuzzi Same result.

siacomuzzi commented 8 years ago

These are my strategy options:

{ scope: [ 'r_basicprofile' ],
  clientID: '...',
  clientSecret: '...',
  callbackURL: 'https://mywebapp.com/login/callback' }

my this.profileUrl value:

https://api.linkedin.com/v1/people/~:(id,first-name,last-name,picture-url,picture-urls::(original),formatted-name,maiden-name,phonetic-first-name,phonetic-last-name,formatted-phonetic-name,headline,location:(name,country:(code)),industry,distance,relation-to-viewer:(distance,connections),current-share,num-connections,num-connections-capped,summary,specialties,positions,site-standard-profile-request,api-standard-profile-request:(headers,url),public-profile-url)

And my profile._json object:

{
  // ...
  pictureUrl: 'https://media.licdn.com/mpr/mprx/...',
  pictureUrls: { _total: 1, values: [Object] },
}

Maybe you can try with a new LinkedIn app?

oieesah commented 8 years ago

Alright. I will let you know.

oieesah commented 8 years ago

Created new LinkedIn app. The response is same as before. No "pictureUrls" exist.

JSteunou commented 8 years ago

Is linkedin expose the same API or same version to everyone, every country ?

Le 10 août 2016 11:04, "Haseeb" notifications@github.com a écrit :

Created new LinkedIn app. The response is same as before. No "pictureUrls" exist.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/auth0/passport-linkedin-oauth2/issues/41#issuecomment-238808034, or mute the thread https://github.com/notifications/unsubscribe-auth/ACNytw1JDcweruYyAq2HWf-bjokTbLNgks5qeZQigaJpZM4IhYjj .

oieesah commented 8 years ago

@JSteunou Sorry, i didn't get your question.

@siacomuzzi Which version of "Passport" you are using?

JSteunou commented 8 years ago

@oieesah I mean, it's weird that some of us get pictureUrls and you do not despite your different tests. So I though, maybe it's not the same API version. Or maybe LinkedIn do not send the same result depending the country we set in our profile due to local laws...

oieesah commented 8 years ago

@JSteunou That's not possible, linkedIn is a global service so does it's API.

siacomuzzi commented 8 years ago

Which version of "Passport" you are using?

passport-linkedin-oauth2@1.4.1

I just created a new LinkedIn app and its works as expected:

image

oieesah commented 8 years ago

On a side note, can we get profile photo without linkedin watermark on them?

siacomuzzi commented 8 years ago

Check LinkedIn API documentation, but I think you can't do that.

oieesah commented 8 years ago

Does full photo from "pictureUrls::(Original)" also contains watermark?

siacomuzzi commented 8 years ago

yes, bottom-right corner

oieesah commented 8 years ago

@siacomuzzi

"picutreUrls.values[0]" value is same as "pictureUrl"?

I am talking in reference to the response you shared.

siacomuzzi commented 8 years ago

No. pictureUrls.values[0] is the original unformatted profile picture. From doc:

oieesah commented 8 years ago

@siacomuzzi I have tried almost all options there is.

  1. Created new apps.
  2. Added all possible callback URLs.
  3. Tried with new Users.

But not getting "picture-urls".

siacomuzzi commented 8 years ago

Try submitting your issue in LinkedIn Dev Support

oieesah commented 8 years ago

@siacomuzzi How i can validate whether my app is making oauth2 call or not?

siacomuzzi commented 8 years ago

Sorry, I don't understand the question. If you are using passport-linkedin-oauth2, then you are making oauth2 calls (https://www.linkedin.com/uas/oauth2/authorization and https://www.linkedin.com/uas/oauth2/accessToken)

oieesah commented 8 years ago

I am using passport-linkedin-oauth2. My response is same as the one i was getting with passport-linkedIn. So i thought may be my web-app isn't really making OAuth2 calls at all.

oieesah commented 8 years ago

@siacomuzzi My app is authorising with linkedIn using https://www.linkedin.com/uas/oauth/authorize?oauth_token=

Why not oauth2? May be this the reason i was not getting the pictureUrls.

siacomuzzi commented 8 years ago

Please debug your app, if you are using passport-linkedin-oauth2, initial request should be https://www.linkedin.com/uas/oauth2/authorization (see https://github.com/auth0/passport-linkedin-oauth2/blob/master/lib/oauth2.js#L8)

oieesah commented 8 years ago

Thanks @siacomuzzi

siacomuzzi commented 8 years ago

@oieesah can I close this issue?

oieesah commented 7 years ago

@siacomuzzi Yes sure!

lavarajallu commented 6 years ago

@siacomuzzi when displaying the pictureUrl in Image tag in react native it is not displaying in android but showing in ios How to solve this?