最近,firebase团队发布了新版本的firebase 3.1,它与react-native兼容。我正试图在facebook上使用新的firebase api。
由于firebase不支持react-native中的弹出或重定向,我使用react-native-fbsdk来获取访问令牌,但是当我尝试使用auth.signInWithCredential时,登录失败
代码:“auth / app-not-authorized”,
消息:“此应用程序,由 托管的域名无权使用Firebase 使用提供的API密钥进行身份验证检查你的钥匙 Google API控制台中的配置。“
这是我的代码。任何帮助都将非常感激。
import { LoginManager, AccessToken} from 'react-native-fbsdk';
import firebase from '../Services/firebase';
const auth = firebase.auth();
const provider = firebase.auth.FacebookAuthProvider;
LoginManager.logInWithReadPermissions(['public_profile'])
.then(loginResult => {
if (loginResult.isCancelled) {
console.log('user canceled');
return;
}
AccessToken.getCurrentAccessToken()
.then(accessTokenData => {
const credential = provider.credential(accessTokenData.accessToken);
return auth.signInWithCredential(credential);
})
.then(credData => {
console.log(credData);
})
.catch(err => {
console.log(err);
});
});
答案 0 :(得分:6)
我们设法找到了问题。似乎firebase给我们的凭据由于某种原因已经过时了
从我们发现的谷歌console,以某种方式生成了一个新的apiKey(可能在升级到firebase 3期间?)并且firebase键被标记为Previous键。
一旦我们在应用程序中更新了新的apiKey,一切都开始工作了。