Guest User

Untitled

a guest
Oct 18th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. func webView(webView: WKWebView, didReceiveAuthenticationChallenge
  2. challenge: NSURLAuthenticationChallenge,
  3. completionHandler: (NSURLSessionAuthChallengeDisposition, NSURLCredential?) -> Void) {
  4.  
  5. let creds = NSURLCredential(user:"username", password:"password", persistence: NSURLCredentialPersistence.ForSession)
  6. completionHandler(NSURLSessionAuthChallengeDisposition.UseCredential, creds)
  7. }
  8.  
  9. Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l
  10.  
  11. extension MyController: WKNavigationDelegate {
  12. func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
  13. guard let u = self.webuser, let p = self.webp else {
  14. completionHandler(.cancelAuthenticationChallenge, nil)
  15. return
  16. }
  17.  
  18. let creds = URLCredential.init(user: u, password: p, persistence: .forSession)
  19. completionHandler(.useCredential, creds)
  20. }
  21. }
Add Comment
Please, Sign In to add comment