Search code examples
iosswiftfirebasefirebase-authenticationazure-active-directory

Swift - Firebase Auth with Microsoft Graph (Redirect URL Problem)


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

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]"

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

  1. Web redirect URL : "*.firebaseapp.com/__/auth/handler"
  2. Supported account types : "Accounts in any organizational directory (Any Azure AD directory Multitenant)"

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?


Solution

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

    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