<commit_before>'use strict';

// Load modules

const Crypto = require('crypto');


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',
        scope: ['r_basicprofile', 'r_emailaddress'],
        scopeSeparator: ',',
        profile: function (credentials, params, get, callback) {

            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 = this.providerParams.fields;
            }

            get('https://api.linkedin.com/v1/people/~' + fields, query, (profile) => {

                credentials.profile = {
                    id: profile.id,
                    name: {
                        first: profile.firstName,
                        last: profile.lastName
                    },
                    email: profile.email,
                    headline: profile.headline,
                    raw: profile
                };
                return callback();
            });
        }
    };
};
<commit_msg>[Fix] Fixes email address field in LinkedIn<commit_after>'use strict';

// Load modules

const Crypto = require('crypto');


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',
        scope: ['r_basicprofile', 'r_emailaddress'],
        scopeSeparator: ',',
        profile: function (credentials, params, get, callback) {

            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 = this.providerParams.fields;
            }

            get('https://api.linkedin.com/v1/people/~' + fields, query, (profile) => {

                credentials.profile = {
                    id: profile.id,
                    name: {
                        first: profile.firstName,
                        last: profile.lastName
                    },
                    email: profile.emailAddress,
                    headline: profile.headline,
                    raw: profile
                };
                return callback();
            });
        }
    };
};

{'fraction_non_alphanumeric': 0.12138521956444127, 'fraction_numerical': 0.004998214923241699, 'mean_word_length': 1.4774535809018567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 6, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1174055', 'n_tokens_mistral': 750, 'n_tokens_neox': 703, 'n_words': 134}