使用令牌的WKWebview身份验证不起作用-Swift

问题描述

我想在WKWebview中打开我的应用程序的授权URL。我已经尝试了stackoverflow和google的所有可能解决方案,但没有一个我有用。


        if let url = myURL {
            var request = URLRequest(url: url)
            request.addValue("3d66fc991e82415398a8e92d8856da3e",forHTTPHeaderField: "Authorization")
            webView.load(request)
        }

我还添加了此代表。

 public func webView(_ webView: WKWebView,didReceive challenge: URLAuthenticationChallenge,completionHandler: @escaping (URLSession.AuthChallengedisposition,URLCredential?) -> Void) {

        let creds = URLCredential(user:"user1",password:"1234",persistence: URLCredential.Persistence.permanent)
        completionHandler(URLSession.AuthChallengedisposition.useCredential,creds)
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)