liveBook · Manning

Client

As explained in Spring Security in Action, Second Edition

An OAuth client is an application that requests authorization and accesses protected resources on behalf of a resource owner.

An OAuth 2 client is an application that requests authorization and accesses protected resources on behalf of a resource owner. It may be a web, mobile, desktop, or backend application. A backend service can act as a client when it calls another protected backend. section 13.1 section 16.0

The client obtains an access token from an authorization server, then presents that token when calling a resource server. The token lets the resource server authorize the requested operation. section 13.1 section 13.6

Choose the client flow according to whether a user participates:

  • Use the authorization code grant when a user signs in. The authorization server authenticates the user, redirects the browser back with an authorization code, and the client exchanges that code for an access token. section 13.3.1
  • Use the client credentials grant when one backend authenticates as itself. The client sends its credentials to the token endpoint and does not need a user, redirect URI, or authorization URI. section 16.2
  • Add PKCE to the authorization code grant when the client needs supplementary protection against stolen authorization codes and credentials. section 13.3

Spring Security client

A Spring MVC application can enable OAuth 2 login with oauth2Login(), require authentication for every request, and configure only client credentials when using a well-known provider such as Google or GitHub. A backend service instead enables oauth2Client(), registers a client-credentials registration, and uses an OAuth2AuthorizedClientManager to obtain an access token. section 16.1.1 section 16.2

How Spring Security in Action, Second Edition covers it

How deep it goes
Explains actors, token flows, grant selection, and Spring configuration, stopping short of detailed OAuth 2 or OpenID Connect expertise.
Examples
Uses Google login, an invoices web application, a backend service, and a /token endpoint that returns a retrieved access token.
What it assumes
Assumes basic Spring Boot and web-application skills while teaching OAuth 2 actors, tokens, and client grant flows.
What you can do after
Build it with Spring Security for external-provider login or service-to-service token retrieval.
How it connects
Connects clients with authorization servers, resource servers, access tokens, authorization code, client credentials, PKCE, and OpenID Connect.

Also explained in

Compare how 15 books explain client →

Related concepts

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