Google Fire使用Firebase登录Chrome中的Chrome扩展程序

阿杰

将Firebase用于通过React创建的带有Chrome扩展程序的Google登录。我已经使用设置了oauth,GoogleConsole并且能够使用chrome扩展名成功进行登录

chrome.identity.getAuthToken({ interactive: true }, function (token) {
if (chrome.runtime.lastError) {
    console.log('It was not possible to get a token programmatically.');
} else if (chrome.runtime.lastError) {
    console.error(chrome.runtime.lastError);
} else if (token) {
    // Authorize Firebase with the OAuth Access Token.
    var credential = firebase.auth.GoogleAuthProvider.credential(null, token);
    firebase.auth().signInWithCredential(credential).catch(function (error) {
        // The OAuth token might have been invalidated. Lets' remove it from cache.
        if (error.code === 'auth/invalid-credential') {
            chrome.identity.removeCachedAuthToken({ token: token }, function () {
                signInWithGoogle();
            });
        }
    });
} else {
    console.error('The OAuth Token was null');
}
});

现在,我想使用react,redux,webext-redux来构建代码。

在firebase的配置中,包括了 apiKey, databaseUrl , storageBucket and authDomain as chrome-extension://key_name.

在Firebase中的Firebase->身份验证->登录->身份验证域下定义了相同的身份验证域。扩展Uncaught Error: Illegal url for new iframe - https://chrome-extension/:auth/iframe?apiKey=secretKeys在尝试登录SignInWithGoogle时引发错误

请让我知道是否需要更多信息。

阿杰

chrome.identity代码从popup.js更改background.js以维护浏览器中用户的单一登录。

Popup.js- > background.js- > execute singin with google

使用webext-reduxreduxredux-thunkfirebase落实Google SignIn with React

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在 Chrome 扩展程序中启用使用 Google 登录?

Google Hangouts Chrome扩展程序中的永久登录按钮;无法登录并使用该应用

Angular Fire (Google) Analytics 事件显示在 Chrome GA 调试工具中,但未登录到 Firebase

在Chrome扩展程序中无法使用Google Analytics(分析)

使用Google用户以外的其他Google用户登录Chrome扩展程序

Firefox中的Google Chrome扩展程序

Chrome扩展程序中的Google Apps脚本?

在Google Chrome扩展程序中获取JSON

在Chrome扩展程序中使用Google图表

搭配UDP使用的Google Chrome扩展程序

更新Google Chrome扩展程序

Google Chrome扩展程序错误

使用Google帐户登录Chrome

如何在Google Chrome扩展程序中启动新窗口

在 Google Chrome 扩展程序中获取打开的弹出窗口

在Google Chrome扩展程序中需要外部JavaScript

阻止扩展程序安装在Google Chrome中

在Google Chrome扩展程序中添加子contextMenus

Google Chrome扩展程序中的getSelection.getRangeAt(0)

Chrome扩展程序:检测Google文档中的按键

如何在Google Chrome扩展程序中获取基本URL

Chrome扩展程序中的Google Analytics(分析)不起作用

如何重定向Google Chrome扩展程序中的某些页面?

字体在Google Chrome扩展程序中不起作用

新标签中的Google Chrome扩展程序默认

Google Chrome 扩展程序 - 从缓存中获取图像

如何在 Google Chrome 扩展程序中编码 GIF?

使用Google Chrome扩展程序导入/导出JSON文件?

Javascript无法在Google Chrome扩展程序中使用