I wanted to build a web app that can view the user's YouTube channel info.
I used Firebase
for authentication with Google and then stored the accessToken
and refreshToken
with the help of the code below.
const provider = new GoogleAuthProvider();
provider.addScope("https://www.googleapis.com/auth/youtube.readonly");
signInWithPopup(auth, provider)
.then(async (result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
const credential = GoogleAuthProvider.credentialFromResult(result);
const accessToken = credential.accessToken;
const refreshToken = result._tokenResponse.refreshToken;
const user = result.user;
localStorage.setItem("accessToken", accessToken);
localStorage.setItem("refreshToken", refreshToken);
localStorage.setItem("user", user);
}
But after the expiry of the accessToken
, it gets invalid.
So, I want to get the newly created accessToken
with help of refreshToken
but I could not find any way to retrieve that.