Skip to content

getRedirectResult always returns null on emulator #6341

@marcusx2

Description

@marcusx2

Operating System

macOS

Browser Version

Safari 16.5.2

Firebase SDK Version

10.1.0

Firebase SDK Product:

Auth

Describe your project's tooling

index.html with source tag.

Describe the problem

getRedirectResult always returns null on emulator. The same code works without using the emulator (on Android, that is. On MacOS Safari it doesn't work with or without emulator, but that's a separate issue).

Steps and code to reproduce issue

Code is very simple. It tries to get the redirect result first, which fails the first time and calls signInWithRedirect. Second time getRedirectResult is supposed to return a user credential, not null.

const app = initializeApp(firebaseConfig);
const auth = getAuth();
connectAuthEmulator(auth, "http://127.0.0.1:9099");


const provider = new GoogleAuthProvider();
provider.addScope('https://www.googleapis.com/auth/contacts.readonly');
provider.setCustomParameters({
	'login_hint': 'user@example.com'
});

try {
    console.log("before redirect");
    let userCredential = await getRedirectResult(auth);
    if (userCredential) {
	const user = userCredential.user;
	console.log("==USER==");
	console.log(user);
	const credential = GoogleAuthProvider.credentialFromResult(userCredential);
	console.log("==CREDENTIAL==");
	console.log(credential);
	const token = credential.accessToken;
	console.log("==TOKEN==");
	console.log(token);
    } else {
        console.log("NO RESULT");
        await signInWithRedirect(auth, provider);
    }
} catch(error) {
    console.error(error);
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions