liveBook · Manning

OAuth

As explained in Spring in Action, Sixth Edition

OAuth 2 is an authorization framework that enables a client to obtain limited access to protected resources on behalf of a resource owner.

OAuth 2 is an authorization framework for granting limited access to protected resources. An authorization server issues access tokens, while a resource server verifies those tokens before allowing API requests. section 8.0 section 8.5

The trust model resembles a valet key: a client receives only the access needed to perform its job, rather than unrestricted control. OAuth 2 secures REST APIs and can also support third-party sign-in; OpenID Connect formalizes that authentication interaction. section 8.0 section 5.3.3

A typical OAuth 2 API interaction works as follows:

  • The client obtains an access token from the authorization server, either for a user or through client token flow. section 8.5
  • The client presents the token when requesting protected API resources. section 8.5
  • The resource server checks that the token is valid, unexpired, and carries the required scope. section 8.5

Third-party sign-in with Facebook

A Spring application can let users sign in through Facebook instead of entering credentials locally. Configure the Facebook client ID and secret, request the email and public_profile scopes, enable oauth2Login(), and link users to /oauth2/authorization/facebook. Protected pages redirect unauthenticated users to Facebook; successful authentication returns them to the application. section 5.3.3

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains authorization servers, resource servers, access tokens, scopes, and Spring configuration without detailing protocol internals.
Examples
Uses valet keys, Taco Cloud Facebook sign-in, client scopes, protected routes, and Spring OAuth2 client configuration.
What it assumes
Assumes familiarity with web applications and APIs while introducing authorization servers, resource servers, tokens, and scopes.
What you can do after
Configure Spring Security OAuth2 clients and understand how authorization servers and resource servers protect API requests.
How it connects
Connects OAuth 2 with REST APIs, authorization servers, resource servers, access tokens, Spring Security, and OpenID Connect.

Also explained in

Compare how 9 books explain OAuth →

Related concepts

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.