[英]Login & Authentication in Chrome Extension Practice
我正在研究chrome擴展並試圖實現一種身份驗證方法(firebase)。 我很困惑,因為popup.html不允許使用內聯腳本,所以它會變得更加困難。 據我所知,有兩種選擇:
從擴展程序調用外部頁面(由我托管),在新選項卡中打開,在那里處理登錄。 但在這種情況下,擴展如何與登錄頁面通信? 餅干? 我需要在popup.js中進行確認
嘗試在Chrome擴展程序彈出窗口中處理電子郵件/密碼登錄,這看起來更復雜。 我總是違反內容安全政策,有點煩人。 我已經嘗試過了,問題是一旦你關閉彈出窗口,就會失去登錄狀態。
我已經研究了很多,但到目前為止還沒有真正好的例子,其他問題幾乎沒有答案。 謝謝!
您可以嘗試在彈出窗口中輸入登錄/密碼輸入框,但在后台頁面中運行實際的登錄代碼。 你可以這樣做,從彈出窗口向后台頁面發送消息,或者直接從彈出窗口發送消息,例如:
popup.html:
<input type="text" id="email">
<input type="password" id="password">
popup.js:
var email = document.getElementById("email").value;
var password = document.getElementById("password").value;
chrome.runtime.getBackgroundPage(function(bgPage){
bgPage.performFirebaseLoginWithEmailAndPassword(email,password);
});
由於后台頁面始終打開,因此應在關閉彈出窗口時保留登錄狀態。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.