From 8942f0fff2fd513f55e744c3771ec83ed781c57b Mon Sep 17 00:00:00 2001 From: AMAICDAX Date: Wed, 3 Sep 2025 11:53:45 +0200 Subject: [PATCH] modif --- controllers/linkedin.js | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) diff --git a/controllers/linkedin.js b/controllers/linkedin.js index ad48960..1e10fff 100644 --- a/controllers/linkedin.js +++ b/controllers/linkedin.js @@ -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);