
# Differences from Spring

`spring_boot_starter_oauth2_client` follows Spring Security's `spring-security-oauth2-client` and `-oauth2-core`, with Spring Boot's auto-configuration and Spring Cloud OpenFeign's OAuth2 interceptor: the same properties, types and rules. This page lists where it does not, and why.

## Why

The package must run in Flutter apps and browsers as well as on servers, so it cannot bring a web server, and every network call is asynchronous. A few behaviours are safer than Spring's defaults, and Sign in with Apple and client-side DPoP are additions.

## Example

```properties
# The same keys as Spring Boot:
spring.security.oauth2.client.registration.keycloak.client-id=neon-web
spring.security.oauth2.client.provider.keycloak.issuer-uri=https://login.example.com/realms/neon
# Spring Cloud's Feign key, without cloud.openfeign:
spring.feign.oauth2.enabled=true
```

## Packaging and properties

| Spring | Here | Why |
|---|---|---|
| `spring-boot-starter-oauth2-client` brings web security and `oauth2Login()` | the client only; a server lists `spring_boot_starter_security`, an app `spring_boot_starter_flutter_security` | It must run where there is no `dart:io` server. |
| `spring.cloud.openfeign.oauth2.*` | `spring.feign.oauth2.*`; the old names stop the start | Spring Cloud means nothing in Dart. |
| Issuer discovery at startup | at the first use; a failure is retried at a use 10 seconds later or more | An app starts while the provider is unreachable. |
| Plain `http://` URIs accepted silently | a warning once per registration outside loopback | Tokens over `http://` can be read and changed. |

## Behaviour

- `ClientRegistrationRepository.findByRegistrationId`, the authorized client service, the manager, the token clients and the user services return `Future`s.
- An `authorization_code` registration without a client secret and without `client-authentication-method` is a public client (`none`), even for a common provider that says `client_secret_basic`.
- PKCE is on for every `authorization_code` registration, confidential clients included, as in Spring Security 7.1.
- The token response clients run on the `HttpTransport` of `spring_web_dart` (Spring 7's `RestClient*TokenResponseClient`).
- `AuthorizedClientServiceOAuth2AuthorizedClientManager` needs its provider (Spring defaults to client credentials alone), runs one authorization at a time per registration and principal, and removes the stored client after `invalid_grant` or `invalid_token`.
- `OAuth2AuthorizedClient` keeps the ID token: the refresh checks a new one against it, and a logout without a session needs it as `id_token_hint`.
- A refreshed ID token is checked as OpenID Connect Core §12.2 says, as Spring Security 6.3's `OidcAuthorizedClientRefreshedEventListener` does.
- The token clients, the user services and an `OidcIdTokenDecoder` are beans (Spring creates them inside its configurers).
- `TokenEndpointOidcIdTokenDecoder` trusts TLS instead of checking the signature; on a server the security starter's bean checks it, as Spring does.
- The issuer metadata lookup is public (`ClientRegistrations.configurationForIssuerLocation`); Spring's is internal.

## Additions

- Sign in with Apple: `CommonOAuth2Provider.apple`, `response-mode` (`ResponseMode`), `OAuth2AuthorizationResponse.fromParameters`, `OAuth2ClientSecretResolver`, `JwtClientSecret` and `JwtClientSecretResolver` (`client-secret-jwt.*`), `native-sign-in`, `JwkSetOidcIdTokenDecoder`. The code token request leaves `redirect_uri` out when the authorization request had none.
- Client-side DPoP: the `dpop` property, `DPoPKey`, `SoftwareDPoPKey`, `DPoPProofBuilder`, `ECDSA.transcodeSignatureToConcat`, and the DPoP parts of the token clients, user services and Feign interceptor.
- `OAuth2AccessTokenErrorDecoder`: a 401 marks the Feign token expired.
- `OAuth2AccessTokenHeaders`: token headers for requests the starter does not make.

## Not supported yet

- `oauth2Login()` itself (the security starter's).
- `private_key_jwt` and `client_secret_jwt` (`client_assertion`), `tls_client_auth`.
- The password, device, token exchange (RFC 8693) and JWT bearer (RFC 7523) grants.
- `@ClientRegistrationId` on HTTP clients.
- A database-backed authorized client service.
- A WebCrypto DPoP key on the web, and the retry of a Feign call answered `use_dpop_nonce`.

## See also

- [Overview](index.md)
- [All properties](properties.md)
- [spring_boot_starter_security differences](../spring-boot-starter-security/differences.md)
