liveBook · Manning

Client id

As explained in Spring Security in Action, Second Edition

A client identifier is an externally visible value that uniquely identifies an OAuth client to an authorization server.

A client ID is an externally visible value that uniquely identifies an OAuth client to an authorization server. Unlike the internal ID, it identifies the client in protocol requests; unlike the client secret, it is not the client’s password. section 14.1

Use the client ID as part of the client’s registered configuration:

  • Set it when registering an application with an OAuth provider, then place it in the client application’s properties. section 16.1.1
  • Configure a separate client ID for each provider when users may authenticate with multiple providers such as Google and GitHub. section 16.1.2
  • Register resource servers as clients with their own client ID and secret when they call an introspection endpoint. section 15.3

Spring Security registration

A Google login uses properties such as spring.security.oauth2.client.registration.google.client-id=790… and a matching client secret. A resource server similarly uses resourceserver.clientID=resource_server when authenticating to the authorization server. section 16.1.1 section 15.3

Listing 14.4 Implementing client details management
@Bean
public RegisteredClientRepository registeredClientRepository() {
  RegisteredClient registeredClient =                         #1
    RegisteredClient                                          #1
        .withId(UUID.randomUUID().toString())                 #1
        .clientId("client")                                   #1
        .clientSecret("secret")                               #1
        .clientAuthenticationMethod(
           ClientAuthenticationMethod.CLIENT_SECRET_BASIC)    #1  
        .authorizationGrantType(                              #1
           AuthorizationGrantType.AUTHORIZATION_CODE)         #1
        .redirectUri("https://www.manning.com/authorized")    #1 
        .scope(OidcScopes.OPENID)                             #1
        .build();                                             #1

  return new InMemoryRegisteredClientRepository
    (registeredClient);                                     #2
}
#1 Creating a RegisteredClient instance
#2 Adding it to be managed by the in-memory RegisteredClientRepository implementation

Inspect the RegisteredClient configuration to see the client ID alongside the internal ID, secret, authentication method, grant type, redirect URI, and scope. section 14.1

How Spring Security in Action, Second Edition covers it

How deep it goes
Defines the identifier and contrasts it with internal IDs and secrets, then applies it in Spring configuration and client registration.
Examples
Uses Google and GitHub application properties, Spring RegisteredClient definitions, and resource-server introspection settings.
What it assumes
Assumes basic OAuth roles and registration, while clarifying client identity from zero within Spring Security examples.
What you can do after
Configure OAuth clients with provider-issued identifiers and distinguish client identification from authentication secrets.
How it connects
Connects client IDs with client secrets, registered clients, authorization servers, grant types, redirect URIs, scopes, and token introspection.

Also explained in

Compare how 2 books explain client id →

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.