Search in sources :

Example 6 with OAuth2AccessTokenResponseClient

use of org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient in project spring-security by spring-projects.

the class OAuth2AuthorizedClientArgumentResolver method updateDefaultAuthorizedClientManager.

private void updateDefaultAuthorizedClientManager(OAuth2AccessTokenResponseClient<OAuth2ClientCredentialsGrantRequest> clientCredentialsTokenResponseClient) {
    // @formatter:off
    OAuth2AuthorizedClientProvider authorizedClientProvider = OAuth2AuthorizedClientProviderBuilder.builder().authorizationCode().refreshToken().clientCredentials((configurer) -> configurer.accessTokenResponseClient(clientCredentialsTokenResponseClient)).password().build();
    // @formatter:on
    ((DefaultOAuth2AuthorizedClientManager) this.authorizedClientManager).setAuthorizedClientProvider(authorizedClientProvider);
}
Also used : ClientCredentialsOAuth2AuthorizedClientProvider(org.springframework.security.oauth2.client.ClientCredentialsOAuth2AuthorizedClientProvider) OAuth2AuthorizedClientProvider(org.springframework.security.oauth2.client.OAuth2AuthorizedClientProvider) DefaultOAuth2AuthorizedClientManager(org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager)

Aggregations

Test (org.junit.jupiter.api.Test)4 HttpServletRequest (jakarta.servlet.http.HttpServletRequest)3 OAuth2AuthorizedClient (org.springframework.security.oauth2.client.OAuth2AuthorizedClient)3 RegisteredOAuth2AuthorizedClient (org.springframework.security.oauth2.client.annotation.RegisteredOAuth2AuthorizedClient)3 ClientRegistration (org.springframework.security.oauth2.client.registration.ClientRegistration)3 DefaultOAuth2AuthorizedClientManager (org.springframework.security.oauth2.client.web.DefaultOAuth2AuthorizedClientManager)3 OAuth2AccessTokenResponse (org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse)3 HttpServletResponse (jakarta.servlet.http.HttpServletResponse)2 MethodParameter (org.springframework.core.MethodParameter)2 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)2 TestingAuthenticationToken (org.springframework.security.authentication.TestingAuthenticationToken)2 ClientCredentialsOAuth2AuthorizedClientProvider (org.springframework.security.oauth2.client.ClientCredentialsOAuth2AuthorizedClientProvider)2 OAuth2AccessTokenResponseClient (org.springframework.security.oauth2.client.endpoint.OAuth2AccessTokenResponseClient)2 OAuth2ClientCredentialsGrantRequest (org.springframework.security.oauth2.client.endpoint.OAuth2ClientCredentialsGrantRequest)2 ClientRegistrationRepository (org.springframework.security.oauth2.client.registration.ClientRegistrationRepository)2 OAuth2AuthorizedClientRepository (org.springframework.security.oauth2.client.web.OAuth2AuthorizedClientRepository)2 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)2 HashMap (java.util.HashMap)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1