繁体   English   中英

ionic - Firebase 身份验证:此域未授权用于 Firebase 项目的 OAuth 操作

[英]ionic - Firebase auth: This domain is not authorized for OAuth oprations for your Firebase project

我正在开发一个 Ionic 应用程序,我需要通过 twitter 登录。 我几天前开发了这个,它运行良好,但最近遇到了这个错误:

“Firebase:此域未被授权执行 Firebase 项目的 OAuth 操作。从 Firebase 控制台编辑授权域列表。(auth/unauthorized-domain-domain)”

  signInWithRedirect() {
const auth = getAuth();
signInWithRedirect(auth, new TwitterAuthProvider())
  .then(() => {
    console.log(window);
    return getRedirectResult(auth);
  })
  .then((result) => {
    const credential = TwitterAuthProvider.credentialFromResult(result);

    // This gives you a Google Access Token.
    // You can use it to access the Google API.
    const token = credential.accessToken;

    // The signed-in user info.
    const user = result.user;
    this.user = user;
    // ...
  })
  .catch((error) => {
    // Handle Errors here.
    const errorCode = error.code;
    const errorMessage = error.message;
    this.error = { errorCode, errorMessage };
  });

}

这是我的 package.json 文件。

 "@angular/common": "~12.1.1",
"@angular/compiler": "~12.1.1",
"@angular/core": "~12.1.1",
"@angular/fire": "^7.0.3",
"@angular/forms": "~12.1.1",
"@angular/platform-browser": "~12.1.1",
"@angular/platform-browser-dynamic": "~12.1.1",
"@angular/router": "~12.1.1",
"@ionic-native/core": "^5.36.0",
"@ionic-native/deeplinks": "^5.36.0",
"@ionic-native/facebook": "^5.36.0",
"@ionic-native/firebase-authentication": "^4.20.0",
"@ionic-native/geolocation": "^5.20.0",
"@ionic-native/sign-in-with-apple": "^5.36.0",
"@ionic-native/twitter-connect": "^5.36.0",
"@ionic/angular": "^5.7.0",
"cordova-plugin-compat": "1.2.0",
"cordova-plugin-customurlscheme": "5.0.2",
"cordova-plugin-facebook-connect": "^3.1.1",
"cordova-plugin-inappbrowser": "5.0.0",
"cordova-universal-links-plugin-fix": "1.2.1",
"firebase": "^9.0.1",

我也将 localhost 添加到了我的授权域(默认添加): 在此处输入图像描述

我的猜测是这是由于离子应用程序的起源是“ionic://localhost”而不是“http://localhost”。

我的 Ionic 版本也是 Firebase 推荐的最新版本: https://firebase.google.com/docs/auth/web/cordova

对此的任何帮助将不胜感激。 谢谢

我认为授权域部分中的本地主机域应如下所示:http://localhost:4200

你能解决吗? 离子5仍然有同样的问题

Reason: You didn't have the firebase app domain itself (*.firebaseapp.com) included in the Accept requests from these HTTP referrers (web sites) list in the Google API credentials for the app key ( https://console.developers .google.com/apis/credentials/key )。

这一定是一个相当新的要求,因为事先只接受来自我的实际站点域的请求就足够了。

来源: https://github.com/firebase/firebase-js-sdk/issues/998

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM