使用Firebase提供的API密钥无效

使用Firebase提供的API密钥无效

本文介绍了使用Firebase提供的API密钥无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm using Firebase Auth to allow users to sign up using Facebook. I have taken all the steps from here to implement sign up including adding GoogleService-Info.plist to my project.

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

I get the Facebook permission screen all fine but when the app hits

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

任何人都可以帮助我吗?

Can anyone help me with this please?

谢谢

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

Here is my function code to log in using 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)
                    }
                }
            }

        }
    })
}


推荐答案

对于将来需要解决方案的任何人来说,

Solved it, for anyone that needs the solution in the future.

有时候,GoogleService-Info.plist中缺少API_KEY ,需要添加。

Sometimes API_KEY is missing from the GoogleService-Info.plist, this needs to be added.

API密钥可以从Google API中找到控制台

The API Key can be found from Google API Console https://console.developers.google.com/

这篇关于使用Firebase提供的API密钥无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 21:18