code: public <T> T doAuthenticatedRequest(
        final StitchAuthRequest stitchReq,
        final Class<T> resultClass,
        final CodecRegistry codecRegistry
    ) {
      final Response response = doAuthenticatedRequest(stitchReq);
  
      try {
        final String bodyStr = IoUtils.readAllToString(response.getBody());
        final JsonReader bsonReader = new JsonReader(bodyStr);
  
        // We must check this condition because the decoder will throw trying to decode null
        if (bsonReader.readBsonType() == BsonType.NULL) {
          return null;
        }
  
        final CodecRegistry newReg =
                CodecRegistries.fromRegistries(BsonUtils.DEFAULT_CODEC_REGISTRY, codecRegistry);
        return newReg.get(resultClass).decode(bsonReader, DecoderContext.builder().build());
      } catch (final Exception e) {
        throw new StitchRequestException(e, StitchRequestErrorCode.DECODING_ERROR);
      }
    }
docs: Performs a request against Stitch using the provided {@link StitchAuthRequest} object, and
  decodes the JSON body of the response into a T value as specified by the provided class type.
  The type will be decoded using the codec found for T in the codec registry given.
  If the provided type is not supported by the codec registry to be used, the method will throw
  a {@link org.bson.codecs.configuration.CodecConfigurationException}.
  
  @param stitchReq     the request to perform.
  @param resultClass   the class that the JSON response should be decoded as.
  @param codecRegistry the codec registry used for de/serialization.
  @param <T>           the type into which the JSON response will be decoded into.
  @return the decoded value.