简体   繁体   English

使用 GoogleAuthProvider() 方法时遇到问题

[英]Facing issue while using GoogleAuthProvider() method

How to use GoogleAuthProvider() method in angular app for authentication in login method?如何在angular应用程序中使用GoogleAuthProvider()方法在登录方法中进行身份验证?

     Angular version: ^12.2.7 
    "@angular/fire": "^7.0.4", 
    "firebase": "^9.1.0",
import { Injectable } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/compat/auth';
// import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFirestore } from '@angular/fire/compat/firestore';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { AppUser } from '../models/appuser';
import * as firebase from 'firebase/compat/app';
import { GoogleAuthProvider } from "firebase/auth";

I'm getting error at:我在以下位置遇到错误:

firebase.GoogleAuthProvider(). async login() { const returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || this.router.url; 
localStorage.setItem('returnUrl', returnUrl); 
const credential = await this.afAuth.signInWithPopup(new firebase.GoogleAuthProvider()); 
return this.updateUserData(credential.user); }

在此处输入图像描述

You can try importing GoogleAuthProvider like this:您可以尝试像这样导入 GoogleAuthProvider:

import { GoogleAuthProvider } from "firebase/auth"

// ...signInWithPopUp(new GoogleAuthProvider())

If you want to use that firebase.auth namespace then you might have to downgrade Firebase to "8.XX" or use compat version for imports:如果您想使用firebase.auth命名空间,那么您可能必须将 Firebase 降级为"8.XX"或使用兼容版本进行导入:

// Add compat if using V9

import firebase from "firebase/compat/app"; 
import "firebase/compat/auth" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 firebase 从 React Native 发送 OTP 时遇到问题 - Facing issue while sending OTP from react native using firebase 使用签名 URL 上传到谷歌云存储时遇到问题 - Facing issue while uploading to Google cloud storage using signed URL 在 redshift 中使用 if else 条件调用存储过程时遇到问题 - Facing issue while calling a stored procedure with if else condition in redshift 使用 Azure 数据块配置 Confluent kafka 时遇到问题 - Facing issue while configuring Confluent kafka with Azure databricks 使用新的刷新令牌订阅 fcm 时遇到问题 - Facing an issue while subscribing to fcm with new refresh token 将 xcom 值与气流 2.3.4 中的静态变量进行比较时遇到问题 - Facing Issue while comparing xcom value to a static variable in airflow 2.3.4 使用 PHP 安装 AWS ClusterClient 时遇到问题 8.1 Amazon Linux 2 - Facing issue while installing AWS ClusterClient with PHP 8.1 Amazon Linux 2 如何将 SignInWithRedirect 与 GoogleAuthProvider 一起使用? - How to use SignInWithRedirect with GoogleAuthProvider? 在使用 AWS Lambda 为 S3 static 网站创建动态联系表单时面临添加目的地的问题 - Facing issues adding destination while creating a dynamic contact form for S3 static website using AWS Lambda aws codepipeline面临权限不足问题 - Aws codepipeline facing insufficient permission issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM