如何在 Android OKHTTPClient 请求上设置(OAuth 令牌)授权标头
2022-09-02 01:50:14
我能够在正常请求上设置身份验证标头,如下所示:HTTPURLConnection
URL url = new URL(source);
HttpURLConnection connection = this.client.open(url);
connection.setRequestMethod("GET");
connection.setRequestProperty("Authorization", "Bearer " + token);
这是HttpURLConnection的标准配置。在上面的代码片段中,是Square的一个实例(这里)。this.client
OkHTTPClient
我想知道是否有设置身份验证标头的特定方法?我看到了该类,但不清楚如何确切地使用它/看起来它只处理身份验证挑战。OkHTTP
OkAuthenticator
提前感谢您的任何指点。