I am trying to get the full size image from google using passport Google Oauth.
I see from other questions that the small size is coming from the "/photo.jpg?sz=50'" at the end of the url string.
since i don't think there is a way to ask for the full size on initial load, what would be the way to remove that part of the url before it gets saved to the database.
One person said to put:
iamgeUrl=user[image][url].substr(0,user[image][url].indexOf('?str=')) + '?sz=100';
but not sure where that would go in my code...
passport.use(
new GoogleStrategy(
{
// options for google strategy
clientID: process.env.googleclientID,
clientSecret: process.env.googleclientSecret,
callbackURL: "/auth/google/redirect"
},
(accessToken, refreshToken, profile, done) => {
console.log(accessToken, refreshToken, profile)
// check if user already exists in our own db
User.findOne({ googleId: profile.id }).then(currentUser => {
if (currentUser) {
// already have this user
done(null, currentUser);
} else {
// if not, create user in our db
new User({
googleId: profile.id,
username: profile.displayName,
thumbnail: profile._json.image.url,
firstName: profile.name.givenName,
lastName: profile.name.familyName,
email: profile.emails[0].value,
})
.save()
.then(user => {
console.log("created new user: ", user);
done(null, user);
});
}
});
}
)
);