I want to let my users send emails in my app through their Gmail account. So, in my front-end, I'm collecting the token generated with
const provider = new firebase.auth.GoogleAuthProvider()
provider.addScope('https://www.googleapis.com/auth/gmail.send')
provider.setCustomParameters({
access_type: 'offline',
prompt: 'consent',
})
firebase.auth()
.signInWithPopup(provider)
.then((result) => {
var credential = result.credential;
var token = credential.accessToken;
})
In my backend, I'm using this token to send emails on their behalf thanks to the Google API. Eveything works well but the token only last one hour...
Do you have any recommandations about the right way to handle this ? Do I need to extend the duration of the token ? Do I have to create a new token every time I want to send an email ? Or do I have to not use firebase to collect the token ?