I am using firebase auth to authenticate users and do things on their behalf. I had this working before, and am having trouble figuring out what's going on now.
I'm using the example from the documentation almost unchanged:
import { getAuth, signInWithPopup, GoogleAuthProvider } from "firebase/auth";
import { initializeApp } from "firebase/app";
const firebaseConfig = {
// ...
};
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
export function signIn() {
const provider = new GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/contacts.readonly');
console.log('before sign in');
signInWithPopup(auth, provider)
.then((result) => {
console.log('success!');
const credential = GoogleAuthProvider.credentialFromResult(result);
const token = credential.accessToken;
const user = result.user;
console.log(token, user);
}).catch((error) => {
console.error(error.code);
});
}
document.addEventListener('click', ()=>signIn());
When I click in the page, this is what happens:
auth/popup-closed-by-user errorThe issue was related to these HTTP headers I configured on my server:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
I added these when I was experimenting with SharedArrayBuffer. Removing them fixed the issue.
For me, I had this error on iOS Emulator if I tried to put this into the Info.plist
<key>FirebaseAppDelegateProxyEnabled</key>
<false/>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With