I am trying to get AppAuth integrated in my app, and I am following their documentation.
Here is what I have so far:
var authorizationRequest = OIDAuthorizationRequest(configuration: configuration,
clientId: clientID,
clientSecret: nil,
scopes: [OIDScopeOpenID, OIDScopeEmail, OIDScopeProfile, "offline_access"],
redirectURL: redirectURI,
responseType: OIDResponseTypeCode,
additionalParameters: nil)
//All of the parameters are intentionally omitted, but are populated prior to this
DispatchQueue.main.async {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.currentAuthorizationFlow = OIDAuthState.authState(byPresenting: authorizationRequest, presenting: self) { authState, error in
if let authState = authState {
self.setAuthState(authState)
}
}
}
And then when I run it, I get the dialog that says "My App" Wants to use "MyApp.com" to Sign in", when I click "Continue" the window appears where the web browser would be, but as soon as it appears it disappears. In the log I do see this:
Task <DBDDE0F0-6C99-4F99-A5B9-B4A602543791>.<6> HTTP load failed, 0/0 bytes (error code: -1003 [12:8])
Task <DBDDE0F0-6C99-4F99-A5B9-B4A602543791>.<6> finished with error [-1003] Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo={_kCFStreamErrorCodeKey=8, NSUnderlyingError=0x28247e970 {Error Domain=kCFErrorDomainCFNetwork Code=-1003 "(null)" UserInfo={_kCFStreamErrorDomainKey=12, _kCFStreamErrorCodeKey=8, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 2ms using unknown from cache, _NSURLErrorNWPathKey=satisfied (Path is satisfied), interface: en0[802.11], ipv4, ipv6, dns, uses wifi}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <DBDDE0F0-6C99-4F99-A5B9-B4A602543791>.<6>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <DBDDE0F0-6C99-4F99-A5B9-B4A602543791>.<6>"
), NSLocalizedDescription=A server with the specified hostname could not be found., NSErrorFailingURLStringKey=..., NSErrorFailingURLKey=..., _kCFStreamErrorDomainKey=12}
And interestingly, my app has 2 pages in it and the login is triggered when the first page is opened. So the first time the app opens I get this behavior, but if I go to the second page and come back the login window stays open and I can login. Any ideas what I am doing wrong?