gpt4 book ai didi

swift - Microsoft 通过 Firebase 登录

转载 作者:行者123 更新时间:2023-11-30 10:32:29 25 4
gpt4 key购买 nike

我对应用程序开发非常陌生,所以请原谅我。我研究了太久,似乎无法理解如何使用 Firebase 为 Microsoft 登录编写登录按钮。这是到目前为止我的代码:

import UIKit
import FirebaseAuth

class LoginViewController: UIViewController {

var ref : DatabaseAuth!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.

}


@IBAction func logIntapped(_ sender: Any) {

let provider = OAuthProvider(providerID: "microsoft.com")
provider.getCredentialWith(nil) { (credential, error) in
if error != nil {
// Handle error.
print("Failed to retreive credential.")
return
}
if credential != nil {
Auth.auth().signIn(with:completion:)(<#AuthCredential#>) { authResult, error in
if error != nil {
// Handle error.
}
}
} else {
print("Credential is nil.")
}
}
}
}

最佳答案

您需要将从 Microsoft 获取的凭据传递到对 Firebase 身份验证的调用中。所以类似:

Auth.auth().signIn(with: credential) { authResult, error in
...

另请参阅 handling the sign-in flow with the Firebase SDK 上的 Firebase 文档.

关于swift - Microsoft 通过 Firebase 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58864591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com