我能够设置验证头正常HTTPURLConnection
请求是这样的:如何设置(OAuth凭证)认证头在Android OKHTTPClient请求
URL url = new URL(source);
HttpURLConnection connection = this.client.open(url);
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer " + token);
这是HttpURLConnection的标准。在上面的代码片段this.client
是Square的一个实例OkHTTPClient
(here)。
我想知道是否有OkHTTP
特定的方式来设置身份验证头?我看到了OkAuthenticator
类,但我不清楚如何使用它/它看起来只处理认证挑战。
在此先感谢任何指针。
嗨,你有没有解决? – CeccoCQ