Spring / Spring7 Intermediate to Advanced Interview questions
How does Spring Security 7 improve OAuth2 client support for HTTP service clients like RestClient?
Spring Security 7 adds OAuth2 support directly into the builders for HTTP service clients, so an outbound call to a protected downstream API can have a bearer token attached automatically instead of the application manually managing token acquisition and refresh in an interceptor.
@Bean @ClientRegistrationId("inventory-service") public InventoryClient inventoryClient(RestClient.Builder builder) { RestClient client = builder.baseUrl("https://inventory.internal").build(); HttpServiceProxyFactory factory = HttpServiceProxyFactory .builderFor(RestClientAdapter.create(client)).build(); return factory.createClient(InventoryClient.class); }
Placing @ClientRegistrationId at the class level, rather than repeating it on every method, is a smaller but meaningful convenience addition - previously each individual call site needed its own registration-id annotation even when a whole client interface always talked to the same downstream service. Together these changes reduce the amount of hand-written token-management plumbing needed for service-to-service OAuth2 calls.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
