{"record":{"id":"d80c95e7c0178fc4","repo":"spring-projects/spring-security","slug":"expected-single-matching-bean-of-type-org-springf-d80c95","errorCode":null,"errorMessage":"Expected single matching bean of type 'org.springframework.security.oauth2.client.OAuth2AuthorizedClientService' but found {}: {}","messagePattern":"Expected single matching bean of type 'org\\.springframework\\.security\\.oauth2\\.client\\.OAuth2AuthorizedClientService' but found (.+?): (.+?)","errorType":"exception","errorClass":"NoUniqueBeanDefinitionException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurerUtils.java","lineNumber":108,"sourceCode":"\t}\n\n\tprivate static <B extends HttpSecurityBuilder<B>> OAuth2AuthorizedClientService getAuthorizedClientService(\n\t\t\tB builder) {\n\t\tOAuth2AuthorizedClientService authorizedClientService = getAuthorizedClientServiceBean(builder);\n\t\tif (authorizedClientService == null) {\n\t\t\tauthorizedClientService = new InMemoryOAuth2AuthorizedClientService(\n\t\t\t\t\tgetClientRegistrationRepository(builder));\n\t\t}\n\t\treturn authorizedClientService;\n\t}\n\n\tprivate static <B extends HttpSecurityBuilder<B>> OAuth2AuthorizedClientService getAuthorizedClientServiceBean(\n\t\t\tB builder) {\n\t\tMap<String, OAuth2AuthorizedClientService> authorizedClientServiceMap = BeanFactoryUtils\n\t\t\t.beansOfTypeIncludingAncestors(builder.getSharedObject(ApplicationContext.class),\n\t\t\t\t\tOAuth2AuthorizedClientService.class);\n\t\tif (authorizedClientServiceMap.size() > 1) {\n\t\t\tthrow new NoUniqueBeanDefinitionException(OAuth2AuthorizedClientService.class,\n\t\t\t\t\tauthorizedClientServiceMap.size(),\n\t\t\t\t\t\"Expected single matching bean of type '\" + OAuth2AuthorizedClientService.class.getName()\n\t\t\t\t\t\t\t+ \"' but found \" + authorizedClientServiceMap.size() + \": \"\n\t\t\t\t\t\t\t+ StringUtils.collectionToCommaDelimitedString(authorizedClientServiceMap.keySet()));\n\t\t}\n\t\treturn (!authorizedClientServiceMap.isEmpty() ? authorizedClientServiceMap.values().iterator().next() : null);\n\t}\n\n\tstatic <B extends HttpSecurityBuilder<B>> OidcSessionRegistry getOidcSessionRegistry(B builder) {\n\t\tOidcSessionRegistry sessionRegistry = builder.getSharedObject(OidcSessionRegistry.class);\n\t\tif (sessionRegistry != null) {\n\t\t\treturn sessionRegistry;\n\t\t}\n\t\tApplicationContext context = builder.getSharedObject(ApplicationContext.class);\n\t\tif (context.getBeanNamesForType(OidcSessionRegistry.class).length == 1) {\n\t\t\tsessionRegistry = context.getBean(OidcSessionRegistry.class);\n\t\t}\n\t\telse {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurerUtils.java#L90-L126","documentation":"During OAuth2 client configuration, getAuthorizedClientServiceBean queries the ApplicationContext for OAuth2AuthorizedClientService beans. This IllegalStateException fires when the lookup does not return exactly one bean (zero found, or more than one candidate), leaving the builder unable to determine which authorized-client service to use. Configuration is ambiguous or missing, so startup fails rather than guessing.","triggerScenarios":"Thrown at config/src/main/java/org/springframework/security/config/annotation/web/configurers/oauth2/client/OAuth2ClientConfigurerUtils.java:108 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Register exactly one OAuth2AuthorizedClientService bean (e.g. a JdbcOAuth2AuthorizedClientService) or mark one @Primary","Remove duplicate OAuth2AuthorizedClientService definitions from the context","Omit the bean entirely to accept the default InMemoryOAuth2AuthorizedClientService backed by getClientRegistrationRepository"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}