[SOLVED] What api to use instead of TokenRelayGatewayFilterFactory for relaying tokens to microservice?


This Content is from Stack Overflow. Question asked by Katlock

I am currently following an example to forward jwt tokens from a spring gateway service to a backend microservice.
The api-gateway example uses org.springframework.cloud.security.oauth2.gateway.TokenRelayGatewayFilterFactory to relay token to backend microservice but it is now deprecated.

It comes from this depenendency:


The following is the existing code that uses the deprecated api:

public RouteLocator customRouteLocator(RouteLocatorBuilder builder, TokenRelayGatewayFilterFactory filterFactory) {
        return builder.routes()
                .route("car-service", r -> r.path("/cars")
                        .filters(f -> f.filter(filterFactory.apply()))

What is the new api to use?


I couldn’t delete it so I will answer my own question.
I changed my spring boot version to following:

 <relativePath/> <!-- lookup parent from repository -->

and I was already referencing this dependency also:


and referenced this import:

This Question was asked in StackOverflow by Katlock and Answered by Katlock It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?