title: Spring OAuth2 Making `state` param at least 32 characters long
body: <p>I am attempting to authorize against an external identity provider. Everything seems setup fine, but I keep getting a validation error with my identity provider because the <code>state</code> parameter automatically tacked onto my authorization request is not long enough:</p>
  
  <p>For example:
  <code>&amp;state=uYG5DC</code></p>
  
  <p>The requirements of my IDP say that this <code>state</code> param must be at least 32-characters long. How can I programmatically increase the size of this auto-generated number?</p>
  
  <p>Even if I could generate this number myself, it is not possible to override with other methods I have seen suggested. The following attempt fails because my manual setting of <code>?state=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz</code> is superceded by the autogenerated param placed after it during the actual request:</p>
  
  <p><code>
      @Bean
      public OAuth2ProtectedResourceDetails loginGovOpenId() {
          AuthorizationCodeResourceDetails details = new AuthorizationCodeResourceDetails() {
              @Override
              public String getUserAuthorizationUri() {
                  return super.getUserAuthorizationUri() + "?state=abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
              }
          };
          details.setClientId(clientId);
          details.setAccessTokenUri(accessTokenUri);
          details.setUserAuthorizationUri(userAuthorizationUri);
          details.setScope(Arrays.asList("openid", "email"));
          details.setPreEstablishedRedirectUri(redirectUri);
          details.setUseCurrentUri(true);
          return details;
      }
  </code></p>
  
  <p>The 6-character setting seems to be set here, is there a way to override this?
  <a href="https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/common/util/RandomValueStringGenerator.java" rel="nofollow noreferrer">https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/main/java/org/springframework/security/oauth2/common/util/RandomValueStringGenerator.java</a></p>