I'm trying to get a user profile picture and save the image URL to my DB. It worked for a while but now I'm starting to see that some of the images aren't loadings anymore... I'm getting 403 (Forbidden).
here is the currently code:
user auth API:
const linkedinAuth = passport.authenticate("linkedin");
router.get("/linkedin", addSocketIdToSession, linkedinAuth);
const addSocketIdToSession = (req, res, next) => {
req.session.socketId = req.query.socketId;
next();
};
paspport.js:
passport.use(new LinkedInStrategy({
clientID: "clientid",
clientSecret: "secret",
scope: ["r_emailaddress", "r_liteprofile"],
callbackURL: linkedinURL,
}, callback));
const callback = async (accessToken, refreshToken, profile, cb) => {
let user = {
email: profile.emails[0].value,
firstName: profile.name.givenName,
lastName: profile.name.familyName,
photo: profile.photos[0].value,
providers: profile.provider,
};
};
I searched and found this option but I see the image URLs I'm getting are the same as I get from the code above.
I think I had something similar with Facebook auth and the fix was to use Facebook API to get the profile image:
photo: https://graph.facebook.com/${profile.id}/picture?type=large