如何使用 Swift 中的新 Firebase 3.2.1 向我的 Firebase 应用程序指定提供程序(Facebook,Google)的用户进行身份验证

How to Authenticate user to my Firebase App specifying the provider (Facebook, Google) with new Firebase 3.2.1 in Swift

我正在更新用 Swift(v2.2) 编写的 iOS 应用程序以使用 Firebase 3.2.1。我更新了我的代码以使用新的 API 通过我的 Firebase 应用程序的电子邮件和密码对我的用户进行身份验证。但是,现在看来我还需要更新我的代码才能使用 Facebook 和 Google 登录。在 Facebook 和 Google 登录过程完成并且用户已登录到 Facebook 或 Google 之后,根据旧文档,我还需要使用以下命令让用户登录到我的 Firebase 应用程序:

  // User is signed in to Facebook!
  // Now, authenticate the user to your Firebase app
  let accessToken = FBSDKAccessToken.currentAccessToken().tokenString
  UserService.firebase.BASE_REF.authWithOAuthProvider("facebook", token: accessToken, withCompletionBlock: { error, authData in
       if error != nil {
          //print("An error occurred!")
       } else {
          //print("User signed in!")
       }

我无法在新 API 中找到与 authWithOAuthProvider() 方法类似的方法。请帮忙,谢谢!

Error: Value of type FIRDatabaseReference has no member authWithOAuthProvider

我将其用于 Facebook 登录,我想它与 Google 几乎相同,只需创建一个适当的凭据即可。

let credential = FIRFacebookAuthProvider.credentialWithAccessToken(FBSDKAccessToken.currentAccessToken().tokenString)
FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in
        // handle logged in user
 }