Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update LinkedIn to use new lite profile #391

Merged
merged 6 commits into from Mar 5, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Fixes linkedin profile requests

  • Loading branch information
dawnerd committed Feb 26, 2019
commit b874e424ce742aed651aef1e138dd3dd5f0b767c
@@ -2,8 +2,6 @@

// Load modules

const Crypto = require('crypto');


// Declare internals

@@ -15,37 +13,31 @@ exports = module.exports = function (options) {
return {
protocol: 'oauth2',
useParamsAuth: true,
auth: 'https://www.linkedin.com/uas/oauth2/authorization',
token: 'https://www.linkedin.com/uas/oauth2/accessToken',
auth: 'https://www.linkedin.com/oauth/v2/authorization',
token: 'https://www.linkedin.com/oauth/v2/accessToken',
scope: ['r_liteprofile', 'r_emailaddress'],
scopeSeparator: ',',
profile: async function (credentials, params, get) {

const query = {
format: 'json',
appsecret_proof: Crypto.createHmac('sha256', this.clientSecret).update(credentials.token).digest('hex')
};

let fields = '';
if (this.providerParams && this.providerParams.fields) {
fields = '?projection=' + this.providerParams.fields;
}

const profile = await get('https://api.linkedin.com/v2/me' + fields, query);
const email = await get('https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))', query);
const profile = await get('https://api.linkedin.com/v2/me' + fields);
const email = await get('https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))');

credentials.profile = {
id: profile.id,
name: {
first: profile.firstName.localized[Object.keys(profile.firstName.localized)[0]],
last: profile.lastName.localized[Object.keys(profile.lastName.localized)[0]]
},
email: email['handle~'].emailAddress,
email: email.elements[0]['handle~'].emailAddress,
This conversation was marked as resolved by AdriVanHoudt

This comment has been minimized.

Copy link
@dawnerd

dawnerd Feb 27, 2019

Author Contributor

Yeah that's what I referred to about their docs being wrong. They send back an elements array.

This comment has been minimized.

Copy link
@AdriVanHoudt

AdriVanHoudt Mar 1, 2019

Contributor

That's... something haha

raw: {
profile,
email
}
};
}
};
};
};
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.