@SuppressWarnings("unchecked")
  private <T> T makePostRequest(
      String baseUrl,
      Optional<Map<String, String>> parameters,
      HttpContent httpContent,
      Class<T> clazz)
      throws IOException, InvalidTokenException, PermissionDeniedException {
    // Wait for write permit before making request
    writeRateLimiter.acquire();

    HttpRequestFactory requestFactory = httpTransport.createRequestFactory();
    HttpRequest postRequest =
        requestFactory.buildPostRequest(
            new GenericUrl(baseUrl + "?" + generateParamsString(parameters)), httpContent);
    postRequest.setReadTimeout(30000); // 30 seconds read timeout
    HttpResponse response;

    try {
      response = postRequest.execute();
    } catch (HttpResponseException e) {
      response =
          handleHttpResponseException(
              () ->
                  requestFactory.buildPostRequest(
                      new GenericUrl(baseUrl + "?" + generateParamsString(parameters)),
                      httpContent),
              e);
    }

    Preconditions.checkState(response.getStatusCode() == 200);
    String result = CharStreams.toString(new InputStreamReader(response.getContent(), UTF_8));
    if (clazz.isAssignableFrom(String.class)) {
      return (T) result;
    } else {
      return objectMapper.readValue(result, clazz);
    }
  }
GoogleMusicHttpApi makes HTTP requests to read and write to the public Google Music's "Music
Library" APIs, following its documentation at
https://developers.google.com/youtube/mediaconnect.

<p>Note that this is the lowest level of Google Music interaction - that is, you probably don't
want to use this class and are better off using something like a bit higher level like the Google
Music DTP Exporter and Importer instead.
extensions/data-transfer/portability-data-transfer-google/src/main/java/org/datatransferproject/datatransfer/google/music/GoogleMusicHttpApi.java