Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func webView(webView: WKWebView, didReceiveAuthenticationChallenge
- challenge: NSURLAuthenticationChallenge,
- completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
- let creds = NSURLCredential(user:"username", password:"password", persistence: NSURLCredentialPersistence.ForSession)
- completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, creds)
- }
- Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
- extension MyController: WKNavigationDelegate {
- func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
- guard let u = self.webuser, let p = self.webp else {
- completionHandler(.cancelAuthenticationChallenge, nil)
- return
- }
- let creds = URLCredential.init(user: u, password: p, persistence: .forSession)
- completionHandler(.useCredential, creds)
- }
- }
Add Comment
Please, Sign In to add comment