Closed biborno closed 10 years ago
oh ! i just found that :( https://github.com/jschell12/passport-linkedin-oauth2 they are fixing bugs here, but when i run npm install passport-linkedin-oauth2 https://github.com/auth0/passport-linkedin-oauth2 this get installed ...my whole day gone in vain :'(
Hi @biborno, @jschell12 is proposing a more flexible approach to get additional profile fields. I'm not sure I get your problem though. Is is that you can't retrieve the e-mail? or you can't call the API? or both?
If the call to the API is failing with the access_token
you get fro LinkedIn, very likely the issue is with the scope you specified. Can you share what API are you calling exactly?
I've tested again with the original implementation and I'm getting the email back when I specify the r_emailaddress
scope. This is when logging in with my account in LinkedIn:
If I login with the r_emailaddress
scope I see:
And then:
Dealing with identity is hard, and precisely one of the reasons we are working on Auth0 (our service): simplify connection with all identity systems like LinkedIn.
@biborno you have to add scope
to your constructor as follows:
var LinkedInStrategy= require('passport-linkedin-oauth2').Strategy
passport.use(new LinkedInStrategy({
clientID: config.linkedIn.clientID,
clientSecret: config.linkedIn.clientSecret,
callbackURL: config.linkedIn.callbackURL,
scope: [ 'r_basicprofile', 'r_emailaddress']
},
I've added an example to this repository
thank u for fixing your code. can u tell me why in the _convertScopeToUserProfileFields only r_basicprofile,r_emailaddress and r_fullprofile have map? what about the other fields? @jfromaniello @eugeniop https://github.com/auth0/passport-linkedin-oauth2 i was using this library. i gave full example of my code. jfromaniello change code accordingly thank u.
Hi @jfromaniello even after adding scope i m unable to get the email address its still showing undefined
.get('/', passport.authenticate('linkedin', { scope: ['r_basicprofile', 'r_emailaddress'] }))
Make sure to enable r_emailaddress
in your linkedin app settings:
Also, check the value of profile._json and try with different users.
Hi, I m very much new on this. it might ( i think it is) my mistake the problem i am facing. i m not been able to retrieve email adress or few other fields. infact only specif fields are return in the callback. here is my code: routing:
passport configuration:
here is console.log(profile):
now here is what i have done, first i tried this:
the result remain same. then i started look into passport-linkedin-oauth code, the scope i m passing from router is recieved here on /lib/oauth.js (on passport-linkedin-oauth2
no matter from where i pass scope here print the same json fields that i recieved firstly.
the parameter I pass from passport configuration middle were is recieved here:
so i change my code into:
still I was not able to get other fields of basci profile such as public profile. then i found on function Strategy, this.profileUrl ._convertScopeTouserProfileFields is called
look on the map 'r_basicprofile': ['id', 'first-name', 'last-name', 'picture-url', 'formatted-name'] there is no public-profile-url fields. so i add it there:
So, I dont think this is the right way to do it. on passport-linkedin there was profileFields that I can pass from passport configuration. but i have to switch in passport-linkedIn-oauth 2 bcoz using passport-linkedIn I was getting a token which is not supported for calling REST api of sharing in linkedIn. So, what I m not getting here. A lot of things I dont know. plz pardon me, if i m issuing something that was my code's error. i dont even know how to use test.