passport-linkedin-oauth2 icon indicating copy to clipboard operation
passport-linkedin-oauth2 copied to clipboard

Error when only r_emailaddress permission is requested

Open tolyakir opened this issue 5 years ago • 1 comments

In case when only r_emailaddress is requested (i.e. no r_liteprofile), the following error is returned:

{ InternalOAuthError: failed to fetch user profile (status: 403 data: {"serviceErrorCode":100,"message":"Not enough permissions to access: GET /me","status":403

It looks like Strategy.prototype.userProfile needs to be updated, to check scope and request profile and/or email accordingly. Currently, the code assumes that r_liteprofile is always granted.

tolyakir avatar Jul 19 '19 01:07 tolyakir

Another issue is if scope is specified in passport.authenticate(): https://gist.github.com/eezhal92/cf6b3892231b4f3c1be4b7055d394283#file-strategy-js-L235

it's not passed to OAuth2Strategy.prototype._loadUserProfile:

https://gist.github.com/eezhal92/cf6b3892231b4f3c1be4b7055d394283#file-strategy-js-L363

tolyakir avatar Jul 19 '19 02:07 tolyakir