我正在使用最新的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
我通过在不同的Web浏览器中使用localhost而不是127.0.0.1解决了这个问题。
此外,对于遇到相同问题的用户,他们需要确保他们的域已经存在于“OAuth重定向域”中,方法是在控制台“Auth”选项卡上进入“SETUP SIGN IN METHOD”。
在尝试了上面列出的所有选项以及其他有关使用FireBase oAuth的网站后,对我有用的解决方案如下:
在此处,找到您在连接到FireBase的应用中使用的API密钥
对于android或ios或在所有三种媒体上使用您的应用程序,您需要为每种媒体创建API密钥。
确保配置中的“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);
如果您使用的是Google Chrome浏览器,则可以看到Identity Toolkit API DISABLE存在问题。您需要在Google云项目中启用此API才能在Firebase项目中获得OAUTH服务。
不是特定于Android,但检查actionCodeSettings
中的地址。
actionCodeSettings.url
必须正确并列入白名单。