Summary
Getting clientRegistrationRepository cannot be null
Actual Behavior
Defined the client reposiroty and providers in application yml but I am still getting error:
Caused by: java.lang.IllegalArgumentException: clientRegistrationRepository cannot be null
at org.springframework.util.Assert.notNull(Assert.java:198)
at org.springframework.security.oauth2.client.InMemoryReactiveOAuth2AuthorizedClientService.
Expected Behavior
The client repository should get created automatically
Configuration
spring.security.oauth2.client.provider.azure.authorization-uri: https://login.microsoftonline.com/common/oauth2/authorize spring.security.oauth2.client.provider.azure.token-uri: https://login.microsoftonline.com/common/oauth2/token spring.security.oauth2.client.provider.azure.user-info-uri: https://login.microsoftonline.com/common/openid/userinfo spring.security.oauth2.client.provider.azure.jwk-set-uri: https://login.microsoftonline.com/common/discovery/keys spring.security.oauth2.client.provider.azure.user-name-attribute: name spring.security.oauth2.client.provider.azure.user-info-authentication-method: query
spring: security: basic: enabled: false oauth2: client: client-id: xx client-secret: xx accessTokenUri: https://login.microsoftonline.com/common/oauth2/token userAuthorizationUri: https://login.microsoftonline.com/common/oauth2/authorize tokenName: oauth_token authenticationScheme: query clientAuthenticationScheme: form scope: openid, https://graph.microsoft.com/user.read tenant: xx registration: azure: client-id: xx client-secret: xx client-authentication-method: basic provider: azure authorizationGrantType: authorization_code redirectUriTemplate: "{baseUrl}/{action}/oauth2/code/{registrationId}" scope: openid, https://graph.microsoft.com/user.read resource: userInfoUri: https://graph.windows.net/xx
Version 2.1.3.RELEASE
Sample
Comment From: jgrandja
@sinisin I'm suspecting this is a configuration issue. Can you please provide more detail, e.g. your security configuration. Also, it is very difficult to read your configuration based on how it's pasted into this issue. Please ensure all content in the issue is readable so we can effectively troubleshoot.
You mention this issue is occurring in 2.1.3? However, this feature is only available in Spring Security 5.x
Comment From: ipsha-sinha-01
Thanks, it was a config issue. I had not provided the scope properly.
Comment From: ayansahavl
Thanks, it was a config issue. I had not provided the scope properly.
It would be great it you can also provide the required changes you made. Thanks ☕