I'm using Firebase Authentication to log in users with Google in my web app. I want to access Google Calendar API on behalf of the user.
Currently, Firebase gives me a Firebase ID token and a temporary Google access token (that expires after an hour) via GoogleAuthProvider.credentialFromResult(result).accessToken, but it does not provide a refresh token.
const handleGoogleLogin = async () => {
const provider = new GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/calendar.events");
provider.setCustomParameters({
approval_prompt: 'force',
access_type: 'offline'
});
const result = await signInWithPopup(auth, provider);
const credential = GoogleAuthProvider.credentialFromResult(result);
console.log(credential);
};
My goal is to be able to create calendar events on behalf of the user without asking them to explicitly approve OAuth consent every time.
Is there a way to use only Firebase Authentication to obtain a long-lived access token or refresh token for Google APIs? I’d like to understand if Firebase can act as a complete bridge to Google APIs, or if OAuth is always required.