Firebase在Swift/iOS中不显示microsoft.com的签名页 [英] Firebase does not show up sign page for microsoft.com in Swift / iOS

查看:55
本文介绍了Firebase在Swift/iOS中不显示microsoft.com的签名页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过使用OAuthProvider类通过个人Microsoft帐户登录来实现Firebase身份验证.

I am implementing the Firebase authentication by using OAuthProvider class to sign in with a personal microsoft account.

我已按照以下说明进行操作: https://firebase .google.com/docs/auth/ios/microsoft-oauth?authuser = 0

I have followed this instructions: https://firebase.google.com/docs/auth/ios/microsoft-oauth?authuser=0

但是,当我使用Firebase SDK的OAuthProvider时,它没有显示Microsoft的登录页面,实际上没有任何内容被getCredentialWith调用.

However when I am using OAuthProvider of Firebase SDK it does not show up the sign in page of Microsoft, actually nothing gets invoked by getCredentialWith.

当我使用GoogleAuthProvider时,一切正常,Firebase SDK会显示Google的登录页面.

When I am using GoogleAuthProvider everything works fine and Firebase SDK shows up the sign in page of Google.

let provider = OAuthProvider(providerID: "microsoft.com")
provider.scopes = ["files.readwrite.appfolder", "user.read"]

provider.getCredentialWith(nil, completion: { credential, error in
  if let error = error {
    os_log("Firebase Error: %@", type: .fault, error as CVarArg)
    return
  }

  if (credential != nil) {
    Auth.auth().signInAndRetrieveData(with: credential!, completion: { authResult, error in
      if let error = error {
        os_log("Firebase Error: %@", type: .fault, error as CVarArg)
        return
      }
    })
  }
})

推荐答案

在全局范围内声明,如下所示

Declare in global scope like below

var provider: OAuthProvider?
var authMicrosoft: Auth?


@IBAction func buttonTapped(_ sender: Any) {


     provider = OAuthProvider(providerID: "microsoft.com")


    provider?.customParameters = [
        "prompt": "consent",
                "login_hint": "",
    ]

    provider?.scopes = ["mail.read", "calendars.read"]




    provider?.getCredentialWith(nil ) { credential, error in
        if error != nil {
            // Handle error.
        }

        print(credential?.provider)



        if let x = credential {
            self. authMicrosoft?.signIn(with: x) { authResult, error in
                if error != nil {
                    // Handle error.
                }


                print(authResult?.additionalUserInfo?.profile)
                print(authResult?.user.providerID)


            }
        } else {

        }

    }

}

这篇关于Firebase在Swift/iOS中不显示microsoft.com的签名页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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