Dear Okta Community,
There is one resource server and client application. From Client application , i am trying to access one API at the resource server through webClient, then i am getting error “org.springframework.web.reactive.function.client.WebClientResponseException$Unauthorized: 401 Unauthorized” . I am using Spring Boot API using Okta OAuth.
-Client Program hosted at port 8080
- Resource Server hosted at port 8081
In the browser , i am trying to access http://localhost:8080/api , which will fetch the data “Made it to protected api on resource server!” from the Resource server , but i am getting 401 Unauthorized Access for the webClient at Client Program.
Rest API at client program is
@GetMapping("/api")
String api() {
return this.webClient
.get()
.uri(this.resourceServerUrl + “/api”)
.retrieve()
.bodyToMono(String.class)
.block();
}
Rest API at Resource Server is
@GetMapping("/api")
String api() {
return “Made it to protected api on resource server!”;
}
Any assistance would be highly appreciated.
Thank You.
Kaushik Mitra