change scope
This commit is contained in:
parent
565b7e547c
commit
cf48f6aa7d
1 changed files with 15 additions and 8 deletions
|
|
@ -6,7 +6,7 @@ const querystring = require("querystring");
|
||||||
const clientId = "780w7gsy8eysmj";
|
const clientId = "780w7gsy8eysmj";
|
||||||
const clientSecret = "WPL_AP1.w6OTTkAndAdT3PYF.UZEcwQ==";
|
const clientSecret = "WPL_AP1.w6OTTkAndAdT3PYF.UZEcwQ==";
|
||||||
const redirectUri = "http://localhost:4200/api/auth/linkedin/callback";
|
const redirectUri = "http://localhost:4200/api/auth/linkedin/callback";
|
||||||
const scope = "openid profile email";
|
const scope = "r_liteprofile r_emailaddress";
|
||||||
|
|
||||||
let accessToken = "";
|
let accessToken = "";
|
||||||
|
|
||||||
|
|
@ -46,18 +46,25 @@ const handleCallback = async (req, res) => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const emailResponse = await axios.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))", {
|
const emailResponse = await axios.get(
|
||||||
headers: {
|
"https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))",
|
||||||
Authorization: `Bearer ${accessToken}`,
|
{
|
||||||
},
|
headers: {
|
||||||
});
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
// Stocke dans la session
|
// Stocke dans la session
|
||||||
req.session.user = {
|
req.session.user = {
|
||||||
accessToken,
|
accessToken,
|
||||||
nom: profileResponse.data.localizedFirstName + " " + profileResponse.data.localizedLastName,
|
nom:
|
||||||
|
profileResponse.data.localizedFirstName +
|
||||||
|
" " +
|
||||||
|
profileResponse.data.localizedLastName,
|
||||||
img: profileResponse.data.profilePicture
|
img: profileResponse.data.profilePicture
|
||||||
? profileResponse.data.profilePicture["displayImage~"].elements[0].identifiers[0].identifier
|
? profileResponse.data.profilePicture["displayImage~"].elements[0]
|
||||||
|
.identifiers[0].identifier
|
||||||
: null,
|
: null,
|
||||||
email: emailResponse.data.elements[0]["handle~"].emailAddress,
|
email: emailResponse.data.elements[0]["handle~"].emailAddress,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue