Spring WebClient for Easy Access to OAuth 2.0 Protected Resources

Spring WebClient for Easy Access to OAuth 2.0 Protected Resources

This tutorial shows how to integrate third-party secure resources with Spring WebClient.

Thank you for the great article! Everything was very well-explained and introduced.

I found a bug in the test - it’s not actually testing that the json is correct (I noticed because there are two typos in the code:

        mockWebServer.enqueue(new MockResponse()
                .addHeader("Content-Type", "application/json; charset=utf-8")
                .setBody("{ \"totalCount\": 9}"));

.expectBody().jsonPath("$.tocalCount", 9);

To make it work, two things need to be updated:

  1. An underscore needs to be added to the JSON value name
  mockWebServer.enqueue(new MockResponse()
                .addHeader("Content-Type", "application/json; charset=utf-8")
                .setBody("{ \"total_count\": 9}"));

and

  1. The final line of the test should be
  .expectBody().jsonPath("$.total_count").isEqualTo(9);

Hopefully this will help others!
Best,
Jessica