liveBook · Manning

Authorized client

As explained in Spring in Action, Sixth Edition

An OAuth2 client registration associated with an authorized resource owner and its obtained access tokens.

An authorized client connects an OAuth2 client registration with the resource owner who authorized it and the access token obtained for that authorization. In a request, Spring retrieves the current authentication, identifies the client registration, and obtains its token. section 8.4

A request-scoped service can use that token when calling a protected API. Request scope matters because Spring populates the SecurityContext during each request, not when application-scoped beans are created. section 8.4

Calling the Taco Cloud API

The taco-admin-client registration is checked on the authenticated request. Its authorized client supplies an access token, which RestIngredientService adds as a Bearer token before requesting ingredients.

How Spring in Action, Sixth Edition covers it

How deep it goes
Traces request scope, authentication checks, client lookup, token extraction, and Bearer-header insertion.
Examples
Uses taco-admin-client and RestIngredientService to retrieve and add Taco Cloud ingredients.
What it assumes
Assumes authenticated requests and introduces the SecurityContext, OAuth2 authentication token, client registration, and access-token lookup.
What you can do after
Operate/configure a Spring OAuth2 client that forwards an authorized user's access token to protected REST endpoints.
How it connects
Links OAuth2 client registration, OAuth2AuthenticationToken, SecurityContext, OAuth2AuthorizedClientService, access tokens, and RestTemplate.

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.