使用 Firebase 进行 Google 登录,并使用 React 创建的 Chrome 扩展程序。我已经使用设置了 oauthGoogleConsole
并能够使用 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 -> Auth -> SignIn -> Auth Domains 下定义了相同的身份验证域。
扩展抛出错误Uncaught Error: Illegal url for new iframe - https://chrome-extension/:auth/iframe?apiKey=secretKeys
尝试使用 Google 登录时。
如果需要更多信息,请告诉我。
移动了chrome.identity
代码来自popup.js
to background.js
维护用户跨浏览器的单点登录。
Popup.js
-> background.js
-> execute singin with google
.
Used webext-redux
, redux
, redux-thunk
, firebase
实施Google SignIn with React
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)