gpt4 book ai didi

javascript - 世博会: "auth/operation-not-supported-in-this-enviroment"

转载 作者:行者123 更新时间:2023-12-03 07:08:38 24 4
gpt4 key购买 nike

我开发了一个 react-native (expo) 移动应用程序并尝试使用 google 帐户登录到 firebase,但出现错误:

"auth/operation-not-supported-in-this-enviroment. This operation is not supported in the enviroment this application is running on. "location.protocol" must be http, https or chrome-extension and web storage must be enabled"



代码:
loginGoogle() {
var provider = new firebase.auth.GoogleAuthProvider();
provider.addScope('profile');
provider.addScope('email');
firebase.auth().signInWithPopup(provider).then(function(result) {
var token = result.credential.accessToken;
var user = result.user;
return true;
}).catch(function(error) {
alert(error.code + '\n' +
error.message + '\n' +
error.email + '\n' +
error.credential);
return false;
});
}

最佳答案

signInWithPopup react-native 不支持。您将需要使用第三方 OAuth 库来获取 OAuth ID token 或访问 token ,然后使用 Firebase 登录:

const cred = firebase.auth.GoogleAuthProvider.credential(googleIdToken, googleAccessToken);
firebase.auth().signInWithCredential(cred)
.then((result) => {
// User signed in.
})
.catch((error) => {
// Error occurred.
});

关于javascript - 世博会: "auth/operation-not-supported-in-this-enviroment",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49966086/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com