Firebase:此域名未经授权

时间:2016-05-20 10:16:55

标签: firebase mobile oauth cors

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

firebase.initializeApp(config);

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

  

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

     

firebase.js:71:1333

11 个答案:

答案 0 :(得分:27)

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

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

答案 1 :(得分:23)

我错过了在授权域名列表中添加我的域名。

  

访问https://console.firebase.google.com/

     

选择您的应用程序并转到左侧菜单“Auth”

     

选择标签“登录方法”

     

在“OAuth重定向域”

中添加您的域名

答案 2 :(得分:7)

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

  1. 登录https://console.cloud.google.com
  2. 转到API&amp;服务&gt;凭证
  3. enter image description here

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

    1. 现在将您的自定义域添加到HTTP Referrers
    2. enter image description here

      enter image description here

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

答案 3 :(得分:6)

确保&#34; authDomain&#34;在您的配置中匹配您的firebase控制台中的那个。如果您在localhost上运行应用程序,请确保它已设置为localhost,并且您的firebase控制台上存在localhost。

验证 - &gt;方法 - &gt; OAuth重定向域

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

答案 4 :(得分:4)

  在Firebase控制台Auth中

->授权域

enter image description here


  

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

enter image description here


  

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

enter image description here

答案 5 :(得分:1)

Firebase用户

对我来说,错误的根源是该域未在Firebase控制台中添加。 这是firebase控制台中的图像,用于为您的网站添加自定义域: firebase console

答案 6 :(得分: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

答案 7 :(得分:0)

对于在Heroku中遇到此问题的人:

确保将 authDomain 属性保持与从Firebase获得的值相同。

请勿将其更改为当前的Heroku域。

答案 8 :(得分:0)

以上所有答案均不适用于我,因为我已在“授权域”列表中拥有本地主机。对我来说,问题是API密钥不正确,我必须以某种方式从其中删除字符之一。当我从signInWithPopup更改为signInWithRedirect时,我得到了更具描述性的(或更确切地说,不是误导性的)错误消息。当API密钥过期时,可能还会发生相同的问题。

答案 9 :(得分:0)

重点是.. 您必须将 yourprojectid.firebaseapp.com 域添加到授权域中.. 不是您的真实域名。这对我有用。

答案 10 :(得分:-1)

并非特定于Android,但请检查actionCodeSettings中的地址。

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

Authenticate with Firebase Using Email Link in JavaScript

相关问题