Firebase auth/argument-error Google Authentication in angular app

Discussão em 'Angular' iniciado por VegDork, Dezembro 23, 2024.

  1. VegDork

    VegDork Guest

    Here is my code in a method within my authentication service (Angular app)

    let provider = new GoogleAuthProvider();

    return this.angularFireAuth.signInWithPopup(provider).then((result) => {result.user});


    This fails and I get Firebase: Error (auth/argument-error).

    I have debugged the error and the point at which it fails is in a firebase method called _assertInstanceOf where it checks whether the authorization provider (in this case GoogleAuthProvider) is a subclass of FederatedAuthProvider - which on examination definitely is.

    function _assertInstanceOf(auth, object, instance) {
    const constructorInstance = instance;
    if (!(object instanceof constructorInstance)) {
    if (constructorInstance.name !== object.constructor.name) {
    _fail(auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
    }
    throw _errorWithCustomMessage(auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */, `Type of ${object.constructor.name} does not match expected instance.` +
    `Did you pass a reference from a different Auth SDK?`);
    }
    }


    The test:

    if (constructorInstance.name !== object.constructor.name)


    Evaluates to

    "FederatedAuthProvider" !== "GoogleAuthProvider"


    And therefore the _fail method is called.

    Is this a bug in the Firebase code or something else?

    My package.json:

    "dependencies": {
    "@angular/animations": "^15.2.0",
    "@angular/cdk": "^15.2.9",
    "@angular/common": "^15.2.0",
    "@angular/compiler": "^15.2.0",
    "@angular/core": "^15.2.0",
    "@angular/fire": "^7.6.1",
    "@angular/forms": "^15.2.0",
    "@angular/material": "^15.2.9",
    "@angular/platform-browser": "^15.2.0",
    "@angular/platform-browser-dynamic": "^15.2.0",
    "@angular/router": "^15.2.0",
    "firebase": "^10.3.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"

    Continue reading...

Compartilhe esta Página