Swift-使用Microsoft Graph进行Firebase身份验证(重定向URL问题)

问题描述:

我在iOS应用中将Firebase与Microsoft Auth集成时遇到问题.

I'm having a problem integrating Firebase with Microsoft Auth in my iOS App.

登录页面已启动,我可以通过Office365帐户登录,但是由于以下错误,无法完成登录身份验证:

The login page has been launched and I can sign in by Office365 account but login auth can not be finished because of the below Error :

"AADSTS50011: The reply url specified in the request does not match the reply urls configured for the application:[app-id]"

我确实检查了Firebase中的设置,以下是我在Azure Active Directory应用程序中添加的设置:

I did check the setting in Firebase and below are the settings I add in the app of Azure Active Directory :

  1. Web重定向URL:"*.firebaseapp.com/__/auth/handler"
  2. 受支持的帐户类型:任何组织目录中的帐户(任何Azure AD目录多租户)"

这是我实现的快速代码:

Here are the swift code I implement :

provider = OAuthProvider(providerID: "microsoft.com")
provider?.customParameters = ["prompt": "consent", 
                              "login_hint": "Login Hint"]

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

provider?.getCredentialWith(_: nil){ (credential, error) in

    if let credential = credential {

        Auth.auth().signIn(with: credential) { (authResult, error) in
            if let error = error {
                print(error.localizedDescription)
            }
        }
    }
}   

有人知道如何解决问题或遇到相同的问题吗?

Does anyone know how to solve the problem or have the same problem?

向这些提供商注册应用程序时,请务必注册* .firebaseapp.com域作为项目的重定向域.

When registering apps with these providers, be sure to register the *.firebaseapp.com domain for your project as the redirect domain for your app.

您是否已将*替换为您的projectName?您可以在firebase控制台的授权域下找到您的授权域.重定向uri应该类似于

Have you replaced * with your projectName? You can find your Authorized Domain under Authorized Domains in firebase console. The redirect uri should be something like

https://yourFirebaseApp.firebaseapp.com/__/auth/handler