Firebase:此域名未经授权

问题描述 投票:26回答:7

我正在使用最新的Firebase JS api(来自firebase.google.com的那个)进入我的Ionic / cordova应用程序,我曾经通过在index.html文件中插入代码来导入它:<script src="https://www.gstatic.com/firebasejs/3.0.0/firebase.js"></script>。这就是我在控制器内部初始化Firebase的方法。我正在使用AngularJS:

firebase.initializeApp(config);

但是,在localhost上启动应用程序到我的浏览器后:我总是得到以下错误:

错误:此域未获授权用于Firebase项目的OAuth操作。从Firebase控制台编辑授权域列表。

firebase.js:71:1333

firebase mobile oauth cors
7个回答
28
投票

我通过在不同的Web浏览器中使用localhost而不是127.0.0.1解决了这个问题。

此外,对于遇到相同问题的用户,他们需要确保他们的域已经存在于“OAuth重定向域”中,方法是在控制台“Auth”选项卡上进入“SETUP SIGN IN METHOD”。


7
投票

在尝试了上面列出的所有选项以及其他有关使用FireBase oAuth的网站后,对我有用的解决方案如下:

  1. 登录https://console.cloud.google.com
  2. 转到API和服务>凭据

enter image description here

在此处,找到您在连接到FireBase的应用中使用的API密钥

  1. 现在将您的自定义域添加到HTTP Referrers

enter image description here

enter image description here

对于android或ios或在所有三种媒体上使用您的应用程序,您需要为每种媒体创建API密钥。


6
投票

确保配置中的“authDomain”与firebase控制台中的“authDomain”匹配。如果您在localhost上运行应用程序,请确保它已设置为localhost,并且您的firebase控制台上存在localhost。

验证 - >登录方法 - > OAuth重定向域

var config = {
    apiKey: "...",
    authDomain: "...", // this should match the one on your firebase console
    databaseURL: "...",
    storageBucket: "",
};
firebase.initializeApp(config);

4
投票

在firebase控制台Auth - >授权域中

enter image description here


必须相等(在Google云端控制台 - > API和服务 - >凭据):

enter image description here


必须相等(在api配置中):

enter image description here


0
投票

问题授权域Firebase Locahost OAUTH2

如果您使用的是Google Chrome浏览器,则可以看到Identity Toolkit API DISABLE存在问题。您需要在Google云项目中启用此API才能在Firebase项目中获得OAUTH服务。

https://console.developers.google.com/apis/api/identitytoolkit.googleapis.com/overview?project=project-id


-1
投票

不是特定于Android,但检查actionCodeSettings中的地址。

actionCodeSettings.url必须正确并列入白名单。

Authenticate with Firebase Using Email Link in JavaScript

© www.soinside.com 2019 - 2024. All rights reserved.