将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-redux
,redux
,redux-thunk
,firebase
落实Google SignIn with React
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句