public static HttpRequest.Builder buildRefreshRequestUrlForAccessToken(
      TokensAndUrlAuthData authData, AppCredentials appCredentials) throws IllegalStateException {
    BodyPublisher postBody = buildRefreshRequestPostBody(authData, appCredentials);
    URI refreshUri = authData.getTokenServerEncodedUri();
    return HttpRequest.newBuilder()
      .uri(refreshUri)
      .POST(postBody)
      .header("content-type", "application/x-www-form-urlencoded");
  }
@Test
  public void test_buildRefreshRequestUrlForAccessToken_detectsIllegalStates() {
    TokensAndUrlAuthData fakeAuthData =
        new TokensAndUrlAuthData(
            "my_access_token", "my_refresh_token", "https://fake-server/auth-url");
    AppCredentials emptyAppCredsMock = mock(AppCredentials.class);
    assertThrows(
        IllegalStateException.class,
        () -> TokenRefresher.buildRefreshRequestUrlForAccessToken(fakeAuthData, emptyAppCredsMock));
  }