modif
This commit is contained in:
parent
f9c3448b86
commit
8942f0fff2
1 changed files with 1 additions and 30 deletions
|
|
@ -39,38 +39,9 @@ const handleCallback = async (req, res) => {
|
|||
|
||||
const accessToken = tokenResponse.data.access_token;
|
||||
|
||||
// Récupère les infos utilisateur
|
||||
const profileResponse = await axios.get("https://api.linkedin.com/v2/me", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
});
|
||||
|
||||
console.log("Profile response:", profileResponse.data); // Log the entire profile response
|
||||
|
||||
const emailResponse = await axios.get(
|
||||
"https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))",
|
||||
{
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
console.log("Email response:", emailResponse.data); // Log the entire email response
|
||||
|
||||
// Stocke dans la session
|
||||
req.session.user = {
|
||||
accessToken,
|
||||
nom:
|
||||
profileResponse.data.localizedFirstName +
|
||||
" " +
|
||||
profileResponse.data.localizedLastName,
|
||||
img: profileResponse.data.profilePicture
|
||||
? profileResponse.data.profilePicture["displayImage~"].elements[0]
|
||||
.identifiers[0].identifier
|
||||
: null,
|
||||
email: emailResponse.data.elements[0]["handle~"].emailAddress,
|
||||
};
|
||||
|
||||
res.send("Authentication successful! User session created.");
|
||||
|
|
@ -87,7 +58,7 @@ const getUserProfile = async (req, res) => {
|
|||
try {
|
||||
const profileResponse = await axios.get("https://api.linkedin.com/v2/me", {
|
||||
headers: {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
Authorization: `Bearer ${req.session.user.accessToken}`,
|
||||
},
|
||||
});
|
||||
res.json(profileResponse.data);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue