这让我很生气,所以在浪费了 3 天的应用“插入式”身份验证解决方案后,将其发布在这里。希望任何人都可以阐明我所缺少的东西。
基本上我已经在仪表板中设置了 faribes 应用程序,并在我的 chrome 扩展程序中成功启动了 farebase。当我删除 firebasUI 进行电子邮件/密码身份验证时,它似乎工作正常 - 它成功检查电子邮件是否存在并显示相应的流程。对于注册,一旦流程完成,它就会在 firebase 数据库中创建一个用户。
问题是 signInSuccess 在登录和注册流程中都不会被调用。而且firebase.auth().onAuthStateChanged(...)
总是返回null
用户
如果我使用普通的,signInWithEmailAndPassword() / createUserWithEmailAndPassword()
一切正常并onAuthStateChanged()
返回正确的用户。
下面是我在 chrome 扩展中使用的代码:
凭据.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);
凭据.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的支持!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句