我能夠設置驗證頭正常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