使用Firebase提供的API密钥无效

我正在使用Firebase身份validation,允许用户使用Facebook注册。 我已经采取了从这里开始的所有步骤来实现注册,包括将GoogleService-Info.plist添加到我的项目中。

我得到的Facebook权限屏幕一切正常,但当应用程序点击

FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in 

返回此错误: 请求中提供了一个无效的API密钥。

任何人都可以帮助我吗?

谢谢

这是我使用Facebooklogin的function代码。

 @IBAction func signUpWithFacebook() { let fbLogin = FBSDKLoginManager() fbLogin.logInWithReadPermissions(["email"], fromViewController:self, handler: { (result, error) -> Void in if ((error) != nil) { print("Process error") } else if (result.isCancelled) { print("Cancelled"); } else { print("Logged in"); let accessToken = FBSDKAccessToken.currentAccessToken().tokenString let credential = FIRFacebookAuthProvider.credentialWithAccessToken(accessToken) print(FBSDKAccessToken.currentAccessToken().tokenString) FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in // ... if let user = user{ print(user.displayName) } else{ if let error = error { print(error.localizedDescription) } } } } }) } 

解决它,为将来需要解决scheme的任何人。

有时API_KEY从GoogleService-Info.plist中丢失,需要添加。

API密钥可从Google API控制台https://console.developers.google.com/中find

您可以通过再次下载Firebase控制台上的“项目设置”部分下的“GoogleService-Info.plist”文件来解决此问题。

确保在新的“GoogleService-Info.plist”上设置了API_KEY。