如何更新GoogleSign-In以使用新的Firebase控制台和API? [英] How do you update GoogleSign-In to work with the new Firebase Console and APIs?

查看:216
本文介绍了如何更新GoogleSign-In以使用新的Firebase控制台和API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我昨天一切正常。然后,我登录到我的Firebase控制台,并有一个横幅提示我尝试新的Firebase控制台。 确定!听起来不错我想。



八小时后,我无法让Google Sign-In工作。这里是我的GIDSignInDelegate方法,它正确的引发了一切。

  func signIn(signIn:GIDSignIn !, 
didSignInForUser user :
let authentication = user.authentication
let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication。 idToken,
accessToken:authentication.accessToken)

FIRAuth.auth()?。signInWithCredential(凭证,完成:nil)
} else {
// Don' t声明这个错误,它通常返回为零
print(\(error.localizedDescription))
}
}

问题似乎是,这不会为

FIRAuth.auth()!. addAuthStateDidChangeListener

这是我的应用程序委托。

使用Facebook API登录时,它会触发auth状态更改侦听器。



也尝试了一个完成块,用户是一个 GIDGoogleUser 而不是 FIRUser 这似乎有点奇怪,但我有没有证据,这将是一个问题。另外,错误是零。所以它看起来像signInWithCredential正在工作,但身份验证状态更改侦听器不会触发。

唯一我能想到的是,有一个问题与谷歌签署 - 作为新的 GoogleService-Info.plist 系统的一部分,我必须从Firebase控制台下载与以前的<$ c $不同的应用程序ID C> GoogleService-Info.plist中。我试图用我的旧的应用程序ID替换,这根本不工作。然后,我尝试删除任何旧的应用程序id的引用,假设新的自动集成谷歌登录。仍然没有运气。



任何人都有成功更新? 修复这个对我来说是创建一个新的Firebase项目。



转到 https://console.firebase.google.com 并选择CREATE NEW PROJECT。我尝试了我在旧的(升级)项目中所能想到的一切,但是我无法完成它。在旧项目中添加一个新的iOS应用程序是不够的。



我知道这是一个生产应用程序不好的选择,但因为我还在开发阶段对我来说不是一件大事。


So, I had everything working as of yesterday. Then I logged into my Firebase dashboard and there was a banner that suggested I try out the new Firebase console. "SURE! That sounds great" I thought.

Eight hours later, I cannot get Google Sign-In to work. Here is my GIDSignInDelegate method, which fires correctly and everything.

  func signIn(signIn: GIDSignIn!,
            didSignInForUser user: GIDGoogleUser!,
            withError error: NSError!) {
            if (error == nil) {
                    let authentication = user.authentication
                    let credential = FIRGoogleAuthProvider.credentialWithIDToken(authentication.idToken,
                                                                                 accessToken: authentication.accessToken)

                    FIRAuth.auth()?.signInWithCredential(credential, completion: nil)
            } else {
                    // Don't assert this error it is commonly returned as nil
                    print("\(error.localizedDescription)")
            }
    }

The problem seems to be that this doesnt create an event for

 FIRAuth.auth()!.addAuthStateDidChangeListener

which is in my app delegate.

When logging in with the Facebook API, it does fire the auth state change listener.

I have also tried with a completion block, the user is a GIDGoogleUser instead of an FIRUser which seems kinda weird, but I have no proof it would be a problem. Also, the error is nil. so it looks like the signInWithCredential is working, but the auth state change listener isnt firing.

The only thing I can think of is that there is a problem with the google sign-in part of the system as the new GoogleService-Info.plist I had to download from the Firebase Console has a different app ID than I had in my previous GoogleService-Info.plist. I tried replacing the new app id with my old one which didn't work at all. I then tried removing any reference to the old app id assuming that the new one integrates google sign in automatically. Still no luck.

Anyone had success updating?

解决方案

What fixed this for me is to create a new Firebase Project.

Go to https://console.firebase.google.com and choose CREATE NEW PROJECT. I tried everything I could think of in my old (upgraded) project and I just couldn't make it work. Also adding a new iOS app inside the old project wasn't enough.

I understand this is a bad option for a production app but as I'm still in the development phase wasn't a big deal for me.

这篇关于如何更新GoogleSign-In以使用新的Firebase控制台和API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆