Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleAuthProvider gives error "this.ta is not a function" in web application

I am trying to set authentication with Google in my web application. I did this type of thing a couple of times on Android apps, but now when i load my application it gives error "this.ta is not a function". Maybe its something silly but i can't detect the problem. Here is what i have:

api.js

import { db, storage, auth, google_provider } from './firebase'
sign_in() {
    auth.signInWithPopup(google_provider).then(result => {
        var token = result.credential.accessToken;
        var user = result.user;
    }).catch(error => {
        var errorCode = error.code;
        var errorMessage = error.message;
        var email = error.email;
        var credential = error.credential;
    })
}

firebase.js

import * as firebase from 'firebase';
const app = firebase.initializeApp({
    apiKey: "my-key",
    authDomain: "domain",
    databaseURL: "https://domain-url",
    projectId: "name",
    storageBucket: "bucket",
    messagingSenderId: "id"
})

export const db = app.firestore()
export const storage = app.storage().ref()
export const auth = app.auth()
export const google_provider = firebase.auth.GoogleAuthProvider()

This is the error GoogleAuthProvider Error

Maybe i am wrong in the way i initialize the GoogleAuthProvider or the way i call the API. If somebody knows something i will appreciate anything that could tell me. Regards.

like image 988
allnuck Avatar asked Dec 11 '22 05:12

allnuck


1 Answers

firebase.auth.GoogleAuthProvideris a constructor. To me it looks like you forgot to initialize it with new.

export const google_provider = new firebase.auth.GoogleAuthProvider()

like image 133
Tor Brekke Skjøtskift Avatar answered Jan 04 '23 23:01

Tor Brekke Skjøtskift