So, I have an electron app and electron apps do not support the firebase/google auth by default. So my question is that I have 1 web app in which I'm using firebase auth. By using firebase auth, I'm using google sign in with it. Now the problem is that I have an electron app in which I want my user to login but since we can't use firebase auth inside electron app, I want that my user should login on the web app, and copy the generated access token from there in to the electron app. So, will it work? I'm getting the token like this:
const credential =
GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
If this access token can be used in any application then how do I get the user's e-mail ID, name etc via any application? Any example/guidance will be really appreciated. My code snippet is below:
signIn = () => {
signInWithPopup(this.auth, this.provider)
.then((result) => {
// This gives you a Google Access Token. You can use it to access the Google API.
//How do I access the google API only via access token?
const credential =
GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
// The signed-in user info.
const user = result.user;
// ...
console.log(token);
console.log(user);
alert(
Dear ${user.displayName}, you are signed in successfully,
);
})
.catch((error) => {
// Handle Errors here.
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
// The AuthCredential type that was used.
const credential =
GoogleAuthProvider.credentialFromError(error);
// ...
alert(Error while signing in: ${error});
});
};