它使我发疯,所以在应用"插入"验证解决方案的3天浪费了几天后将其发布在此处。希望任何人都可以阐明我缺少的东西。
基本上,我已经在仪表板上设置了Faribes应用程序,并在我的Chrome扩展程序中成功地输入了票价。当我将Firebasui用于电子邮件/密码身份验证时,它似乎可以正常工作 - 它成功检查了电子邮件是否存在,并显示了相应的流程。为了注册,它在流量完成后在Firebase数据库中创建用户。
问题在于,在标志中也没有在注册流中均未调用signinsuccess。此外,firebase.auth().onAuthStateChanged(...)
总是返回null
用户
如果我使用普通signInWithEmailAndPassword() / createUserWithEmailAndPassword()
,一切正常,onAuthStateChanged()
返回正确的用户。
以下是我在Chrome扩展中使用的代码:
recretentials.js(弹出脚本):
//init firebase
var config = {
apiKey: "<my_key>",
authDomain: "<my_domain>",
databaseURL: "<my_dburl>",
projectId: "<my_projectid>",
storageBucket: "<my_storagebucket>",
messagingSenderId: "<my_id>"
};
firebase.initializeApp(config);
//ui config for firebaseUI
var uiConfig = {
signInSuccessUrl: 'http://google.com',
credentialHelper: firebaseui.auth.CredentialHelper.NONE,
callbacks: {
signInSuccess: function(currentUser, credential, redirectUrl) {
console.log('sign in success');
console.log(currentUser);
// alert(currentUser)
return false;
},
uiShown: function () {
console.log("uiShow");
}
},
signInFlow: 'popup',
signInOptions: [{
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
requireDisplayName: false
}]
};
//launch the firebaseUI flow
var ui = new firebaseui.auth.AuthUI(firebase.auth());
ui.start('#firebaseui-auth-container', uiConfig);
recretentials.html(弹出html):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample FirebaseUI App</title>
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.css" />
<script src="credentials.js"></script>
</head>
<body>
<!-- The surrounding HTML is left untouched by FirebaseUI.
Your app may use that space for branding, controls and other customizations.-->
<h1>Welcome to My Awesome App</h1>
<div id="firebaseui-auth-container"></div>
</body>
</html>
清单:
{
"manifest_version": 2,
"name": "Some Name",
"description": "Some description",
"version": "0.1",
"icons": {
"128": "icon.png"
},
"browser_action": {
"default_icon": "icon.png",
"default_popup": "credentials.html"
},
"background": {
"page": "background.html"
},
"permissions": [
"identity",
"https://*/*",
"activeTab",
"background"
],
"content_security_policy":"script-src 'self' https://www.gstatic.com https://apis.google.com https://www.googleapis.com https://securetoken.googleapis.com https://*.firebaseio.com https://cdn.firebase.com https://www.google.com; object-src 'self'",
"oauth2": {
"client_id": "<numbers.letters.apps.googleusercontent.com>",
"scopes": [
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/userinfo.profile"
]
},
"key":"<my_chrome_extension_key>"
}
注意:似乎我可以放任何client_id
,并且没有任何区别(firebaseUI
不起作用,firebase
无论如何都可以使用)
我正在遵循此github步骤,并使用了repo
的代码库任何输入都非常感谢。
看起来是firebaseui中的错误:
而不是使用此链接:
<script src="https://cdn.firebase.com/libs/firebaseui/2.5.1/firebaseui.js"></script>
我现在正在使用这个:
<script src="https://www.gstatic.com/firebasejs/ui/2.5.1/firebase-ui-auth.js"></script>
现在起作用 - 感谢Bojeil -Google的支持!