简体   繁体   English

如何在WKWebView中获取令牌?

[英]How to get token in WKWebView?

I make request with my data. 我用我的数据提出请求。 I want to get token from Instagram API. 我想从Instagram API获取令牌。 When I paste my url in browser, I see token. 当我在浏览器中粘贴我的网址时,我会看到令牌。 But I need to get it programmatically. 但我需要以编程方式获得它。 How can I do it? 我该怎么做?

 webView.load(URLRequest(url: url))

You just want to read the token from the header? 你只是想从标题中读取令牌? You could try this. 你可以试试这个。 Set: 组:

webView.navigationDelegate = self

And then in the WKNavigationDelegate method: 然后在WKNavigationDelegate方法中:

func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
    print(navigationAction.request.allHTTPHeaderFields)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM