skip to Main Content

My App uses the Firebase Auth SDK (10.4.0) to authenticate users with OAuth. In my project settings I enabled OpenID Connect as a Sign-In-Method. I use an education institute named "IServ" as my openid auth provider. They have provided me with the ClientID, Issuer-URL and the Client Secret which I entered in the firebase console. I am able to launch the login form of my provider in a WebView with the following code:

let oAuthProvider = OAuthProvider(providerID: "oidc.iserv")
    
oAuthProvider.scopes = ["roles"]

oAuthProvider.getCredentialWith(nil) { credential, error in
    print(credential, error)
}

After entering the login information in the login form of my provider and pressing continue the browser strangely redirects to a white webpage and after a few seconds it redirects to "about:blank".

I have two iOS Apps that are both connected to the same Firebase project. In one of the two apps the oauth login is working and the user gets redirected to the app (i.e. the WebView closes automatically). But in my other app the redirect is not working, although its the exact same code.

I can’t retrieve any error in my Xcode console, nor in the WebView. Is this a common issue and has this something to do with the Xcode project setup?

I would really appreciate some help regarding this.

2

Answers


  1. I had the same issues in a SwiftUI app, which I solved with the following approach.

    Just before the about:blank is loaded, the app’s callback onOpenURL is called (it’s just the SwiftUI version of UIApplicationDelegate application:openURL:options).

    In the callback, add the following code that triggers the authentication flow continuation:

    .onOpenURL { url in
        let authCanHandle = Auth.auth().canHandle(url)
        if authCanHandle {
            return
        }
        /* Here other dynamic link stuff */
    }
    
    Login or Signup to reply.
  2. This did the trick, for AppDelegate add the following code

    func application(_ app: UIApplication, open url: URL, options: func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        let twitterhandeled = Auth.auth().canHandle(url)
        return twitterhandeled
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search