firebase-ios-sdk: Firebase Auth with Microsoft (Azure AD) - Login not possible - "Unable to process request due to missing initial state"
[REQUIRED] Step 1: Describe your environment
- Xcode version: XCode 12.2 (12B45b)
- Firebase SDK version: 7.3.0
- Installation method: CocoaPods
- Firebase Component: Auth
[REQUIRED] Step 2: Describe the problem
Steps to reproduce:
When logging in to Firebase with Microsofts Azure AD as an authentication service by using provider.getCredentialWith(_: nil) I am able to open the Microsoft login page.
After entering the correct email + password then the following error appears inside the In-App-Browser:
“Unable to process request due to missing initial state. This may happen if browser sessionStorage is inaccessible or accidentally cleared.”
- The problem appears no matter if I set Chrome or Safari as a standard browser in iOS settings.
- It happens on real devices (iPhone and iPad, iOS 14.2/14.3 and others), but not every user is affected. Most users can login without any problems.
- I can’t determine in what kind of circumstances the problem occurs, but on a device where the problem occurs, it is always reproducable.
What did work for me as a workaround: In my completion handler of provider.getCredentialWith(_: nil) I call the same function with a delay of 1second again if an error was thrown. On the second run it always succeeds and gives me the credentials back.
Relevant Code:
provider.getCredentialWith(_: nil){credential, error in
if error != nil {
self.errorText = "Error"
return
}
if let credential = credential {
firebaseSignIn(credential: credential)
}
}
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 10
- Comments: 21 (3 by maintainers)
Just commenting to mention that this is still an existing important problem.
same issue for google sign in on web
Hi, I encountered the same issue when trying to use the OauthProvider for an OpenID connector configured for a Google workspace.
I found a workaround by forking
FirebaseAuthand using anASWebAuthenticationSessioninstead of theSFSafariViewControllerto open the authentication URL. You can find the implementation here : https://github.com/kraaft-co/firebase-ios-sdk/commit/3b47b1928eda255ab37525ce91711ef448b6f148There are some side effects :
prefersEphemeralWebBrowserSession).If this proposition seems promising, I would be happy to help building a PR based on this.
I can confirm the solution that @mortenbekditlevsen described. I had no problems with logging in with Azure AD until today when I received the above error message (almost) all the time. 9 out of 10 times I was not able to login, but sometimes it just went through fine. Disabling “Prevent Cross-Site Tracking” however fixed the issue, and I’m able to login every single time. I hope a solution will be found that does not require the user to change this cross-site tracking option for Safari.
I tried all of the methods listed in the link but didn’t work. interesting thing is, when I signInWithPopup it works fine, but when I access the app from microsoft azure ad myapp list, it fails at the https://******/__/auth/handler. trying to implement SSO-SAML here.
Any update on this issue?
Same issue.