title: Spring boot, Security, OAuth2: Is possible to use custom AuthorizationCodeResourceDetails? Auth server requires specific params in redirect url
body: <p>I'm developing an OAuth2 Client with SpringBoot. A third-party auth server requires specific params in redirect urls.</p>
  
  <p>My app.yml</p>
  
  <pre><code> acme:
      client:
        clientId:     acme
        clientSecret: acmepassword
        accessTokenUri:       http://localhost:8080/sso/oauth/token
        userAuthorizationUri: http://localhost:8080/sso/oauth/authorize
        specificParam1: specific1
        specificParam2: specific2
  
      resource:
        userInfoUri:    http://localhost:8080/sso/api/me
  </code></pre>
  
  <p>I've created my <code>CustomClientResourceDetails</code> by extending from <code>AuthorizationCodeResourceDetails</code>.</p>
  
  <pre><code>public class CustomClientResourceDetails extends AuthorizationCodeResourceDetails {
      private String specificParam1;
      private String specificParam2;
      ...    
  }
  </code></pre>
  
  <p>And @Autowire it in my SecurityConfig. I've also created a custom filter</p>
  
  <pre><code>  @Configuration
      @EnableOAuth2Client
      public class SecurityConfiguration extends WebSecurityConfigurerAdapter {      
          @Autowired
          OAuth2ClientContext oauth2ClientContext;
  
          @Override
          protected void configure(HttpSecurity http) throws Exception {
           ...
          .addFilterBefore(ssoFilter(), BasicAuthenticationFilter.class);
       }
  
          @Bean
          public FilterRegistrationBean&lt;OAuth2ClientContextFilter&gt; oauth2ClientFilterRegistration(OAuth2ClientContextFilter filter) {
              FilterRegistrationBean&lt;OAuth2ClientContextFilter&gt; registration = new FilterRegistrationBean&lt;OAuth2ClientContextFilter&gt;();
              registration.setFilter(filter);
              registration.setOrder(-100);
              return registration;
          }
  
          private Filter ssoFilter() {
              OAuth2ClientAuthenticationProcessingFilter customFilter = new OAuth2ClientAuthenticationProcessingFilter(LOGIN);
              OAuth2RestTemplate customTemplate = new OAuth2RestTemplate(custom(), oauth2ClientContext);
              customFilter.setRestTemplate(customTemplate);
              UserInfoTokenServices tokenServices = new UserInfoTokenServices(customResource().getUserInfoUri(),
                      custom().getClientId());
              tokenServices.setRestTemplate(customTemplate);
              customFilter.setTokenServices(
                      new UserInfoTokenServices(customResource().getUserInfoUri(), custom().getClientId()));
              return customFilter;
          }
  
          @Bean
          @ConfigurationProperties("acme.client")
          @Primary
          public AuthorizationCodeResourceDetails custom() {
              return new CustomClientResourceDetails();
          }
  
          @Bean
          @ConfigurationProperties("acme.resource")
          public ResourceServerProperties customResource() {
              return new ResourceServerProperties();
          }
      }
  </code></pre>
  
  <p>But specific param don't included in redirect url because <code>OAuth2ClientAuthenticationProcessingFilter</code> and the associated with it classes work via <code>OAuth2RestOperations</code> or 'OAuth2ProtectedResourceDetails' where only default params.</p>
  
  <p><strong>Is it possible include additional params to redirect urls? And how?</strong></p>
  
  <p>Thanks for any help!</p>