我使用Firebase Auth允许用户使用Facebook注册.我从这里采取了所有步骤来实施注册,包括将GoogleService-Info.plist添加到我的项目中.
我得到的Facebook权限屏幕一切正常,但应用程序命中
FIRAuth.auth()?.signInWithCredential(credential) { (user,error) in
将返回此错误:请求中提供了无效的API密钥.
有人可以帮我吗
谢谢
@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) } } } } }) }
解决方法
解决它,对于任何需要解决方案的人来说.
有时候,GoogleService-Info.plist中缺少API_KEY,因此需要添加.
API Key可从Google API Console https://console.developers.google.com/找到