Session completion handler not being called for ASWebAuthenticationSession

I am trying to use ASWebAuthenticationSession web view. After the authentication is complete, the session completion handler is not being called. Hence, the web view doesn't dismiss.

Below is the piece of code I am using :


guard let authURL = URL(string: "https://github.com/login/oauth/authorize?client_id=<client_id>/") 
else { return }
let scheme = "octonotes"
session = ASWebAuthenticationSession.init(url: authURL, callbackURLScheme: scheme, completionHandler: { callbackURL, error in
  // Handle the callback.
  print(callbackURL!)
  print(error!)  
  })
session?.presentationContextProvider = self
session?.start()


I have set the callback url scheme in info.plist. The same is updated in Targets -> info -> URL


After running the above code, ASWebAuthenticationSession web view is presented, which provides user with sign in page. Once the authentication is complete, web view does not dismiss unlike WKWebView. There is cancel option on top left of the web view, it calls the completion handler with error.


Is there a way to dismiss webview after the authentication session is complete?

I never used.


But are sure of the scheme ?


May look here:

h ttps://dev.to/robotsquidward/quick-guide-to-aswebauthenticationsession-api-changes-in-ios-13-4m8i

Did you figure it out?

Session completion handler not being called for ASWebAuthenticationSession
 
 
Q