title: Consuming One-Shot ResponseBody from Okhttp causes issues with Retrofit
body: <p>I am using an Retrofit with an Okhttp interceptor in order to detect if my oauth token has expired. If the token has expired, I want to request a new token, try the request again, then send that response to Retrofit.</p>
  
  <p>Here is my interceptor class:</p>
  
  <pre><code>public class CustomInterceptor implements Interceptor {
  
  @Override
  public Response intercept(Chain chain) throws IOException {
      Request request = chain.request();
  
      // try the request
      Response response = chain.proceed(request);
  
      if (response.body().string().contains(Constants.TOKEN_AUTH_ERROR_MESSAGE)) {
          Log.v("retrofit_error", "token expired");
  
          //get current token, create headers
          OAuthTokenResponse expiredToken = SharedPreferencesUtil.getOAuthToken();
  
          OAuthTokenResponse newOauthToken = RestClient.getInstance().getTokenService().refreshOauthToken(expiredToken.getRefreshToken());
  
          //store new token, return
          SharedPreferencesUtil.saveOAuthToken(newOauthToken);
  
          // create a new request and modify it accordingly using the new token
          Request.Builder newRequestBuilder = request.newBuilder()
                  .removeHeader("Authorization");
  
          Request newRequest = newRequestBuilder.addHeader("Authorization", SharedPreferencesUtil.getOAuthToken().getAccessToken()).build();
          // retry the request
          return chain.proceed(newRequest);
      }
  
      // otherwise just pass the original response on
      return response;
  }
  
  }
  </code></pre>
  
  <p>The issue is that calling response.body.string() will consume the ResponseBody due to it being a one-shot value as the Okhttp docs state.</p>
  
  <p>This means that the Response returned at the end of the code will no longer container the body when it is passed off to retrofit. Is there any way that I can consume the body while still returning it with the response?</p>
  
  <p>Thanks!</p>