I am trying to authenticate an user through ASWebAuthenticationSession, and after that redirect to an URL that uses the callback scheme.
The authentication page URL is correctly loaded on a browser thanks to ASWebAuthenticationPresentationContextProviding.
But after form completed and authentication successfully, what I am doing is a redirect directly from my server to "http://localhost:5000/ios/hola?hola=hola"
I am trying to catch this URL using a callbackScheme in my iOS app, using the same url that the one which I redirected the browser to, but this is not working.
I also tried to create a Scheme URL to my identifier, and pass it to the callbackScheme, but this is not working either. Documentation is not very clear at how to manage the authentication callback and as a beginner I don't know the way to solve this.
Some help would be appreciated. Thank you for your time!
PD: This is the code of my class
Code Block @available(iOS 12.0, *) class AuthView: UIViewController { var authSession: ASWebAuthenticationSession! override func viewDidLoad() { super.viewDidLoad() if #available(iOS 13.0, *) { configureAuthSession() } } @available(iOS 13.0, *) private func configureAuthSession() { let urlString = "http://localhost:3000/" guard let url = URL(string: urlString) else { return } let callbackScheme = "http://localhost:5000/ios/matriga/hola" authSession = ASWebAuthenticationSession(url: url, callbackURLScheme: callbackScheme) { (callbackURL, error) in guard error == nil, let successURL = callbackURL else { return } let code = NSURLComponents(string: (successURL.absoluteString))?.queryItems?.filter({ $0.name == "code" }).first } authSession.presentationContextProvider = self authSession.start() } } @available(iOS 12.0, *) extension AuthView: ASWebAuthenticationPresentationContextProviding { @available(iOS 12.0, *) func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor { return self.view.window ?? ASPresentationAnchor() } }