ios – 使用Firebase提供的无效API密钥

我使用Firebase Auth允许用户使用Facebook注册.我从这里采取了所有步骤来实施注册,包括将GoogleService-Info.plist添加到我的项目中.

我得到的Facebook权限屏幕一切正常,但应用程序命中

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

将返回此错误:请求中提供了无效的API密钥.

有人可以帮我吗

谢谢

这是我使用Facebook登录功能代码.

@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/找到

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...