title: Spring security oauth 2 simple example
body: <p>I try to implement my own example based on official tutorial <a href="https://github.com/spring-projects/spring-security-oauth/tree/master/samples/oauth2" rel="nofollow"><strong>Sparklr2/Tonr2</strong></a>. Everything looks good but when I remove from <code>web.xml</code> in my <strong>Tonr2</strong> implementation, spring security filter I have exception: </p>
  
  <blockquote>
    <p>No redirect URI has been established for the current request</p>
  </blockquote>
  
  <p>I can't understand what URL should I use. Here is my code, for client implementation:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;!--apply the oauth client context --&gt;
  &lt;oauth:client id="oauth2ClientFilter" /&gt;
  
  &lt;!--define an oauth 2 resource for sparklr --&gt;
  &lt;oauth:resource id="provider" type="authorization_code" client-id="client" client-secret="secret" 
      access-token-uri="http://localhost:8080/provider/oauth/token" user-authorization-uri="http://localhost:8080/provider/oauth/authorize" scope="read,write" /&gt;
  
  &lt;beans:bean id="clientController" class="com.aouth.client.ClientController"&gt;
      &lt;beans:property name="trustedClientRestTemplate"&gt;
          &lt;oauth:rest-template resource="provider" /&gt;
      &lt;/beans:property&gt;
  &lt;/beans:bean&gt;
  </code></pre>
  
  <p>And for provider:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;http pattern="/oauth/token" create-session="stateless" authentication-manager-ref="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;intercept-url pattern="/oauth/token" access="IS_AUTHENTICATED_FULLY" /&gt;
      &lt;anonymous enabled="false" /&gt;
      &lt;http-basic /&gt;
  &lt;/http&gt;
  
  &lt;authentication-manager id="clientAuthenticationManager" xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;authentication-provider user-service-ref="clientDetailsUserService" /&gt;
  &lt;/authentication-manager&gt;
  
  &lt;bean id="clientDetailsUserService" class="org.springframework.security.oauth2.provider.client.ClientDetailsUserDetailsService"&gt;
      &lt;constructor-arg ref="clientDetails" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- The OAuth2 protected resources are separated out into their own block so we can deal with authorization and error handling 
      separately. This isn't mandatory, but it makes it easier to control the behaviour. --&gt;
  &lt;http pattern="/secured" create-session="never" access-decision-manager-ref="accessDecisionManager" xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;anonymous enabled="false" /&gt;
      &lt;intercept-url pattern="/secured" access="ROLE_USER,SCOPE_READ" /&gt;
      &lt;custom-filter ref="resourceServerFilter" before="PRE_AUTH_FILTER" /&gt;
      &lt;http-basic /&gt;
  &lt;/http&gt;
  
  &lt;bean id="accessDecisionManager" class="org.springframework.security.access.vote.UnanimousBased" xmlns="http://www.springframework.org/schema/beans"&gt;
      &lt;constructor-arg&gt;
          &lt;list&gt;
              &lt;bean class="org.springframework.security.oauth2.provider.vote.ScopeVoter" /&gt;
              &lt;bean class="org.springframework.security.access.vote.RoleVoter" /&gt;
              &lt;bean class="org.springframework.security.access.vote.AuthenticatedVoter" /&gt;
          &lt;/list&gt;
      &lt;/constructor-arg&gt;
  &lt;/bean&gt;
  
  &lt;oauth:resource-server id="resourceServerFilter" resource-id="resource" token-services-ref="tokenServices" /&gt;
  
  &lt;bean id="tokenServices" class="org.springframework.security.oauth2.provider.token.DefaultTokenServices"&gt;
      &lt;property name="tokenStore" ref="tokenStore" /&gt;
      &lt;property name="supportRefreshToken" value="true" /&gt;
      &lt;property name="clientDetailsService" ref="clientDetails"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="tokenStore" class="org.springframework.security.oauth2.provider.token.InMemoryTokenStore" /&gt;
  
  &lt;http auto-config="true" xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;intercept-url pattern="/test" access="ROLE_USER" /&gt;
      &lt;intercept-url pattern="/" access="IS_AUTHENTICATED_ANONYMOUSLY" /&gt;
  &lt;/http&gt;
  
  &lt;authentication-manager alias="authenticationManager" xmlns="http://www.springframework.org/schema/security"&gt;
      &lt;authentication-provider&gt;
          &lt;user-service&gt;
              &lt;user name="pr" password="pr" authorities="ROLE_USER" /&gt;
          &lt;/user-service&gt;
      &lt;/authentication-provider&gt;
  &lt;/authentication-manager&gt;
  
  &lt;oauth:authorization-server client-details-service-ref="clientDetails" token-services-ref="tokenServices" &gt;
      &lt;oauth:authorization-code /&gt;
      &lt;oauth:implicit /&gt;
      &lt;oauth:refresh-token /&gt;
      &lt;oauth:client-credentials /&gt;
      &lt;oauth:password /&gt;
  &lt;/oauth:authorization-server&gt;
  
  &lt;oauth:client-details-service id="clientDetails"&gt;
      &lt;oauth:client client-id="client" resource-ids="resource" authorized-grant-types="authorization_code, implicit"
          authorities="ROLE_CLIENT" scope="read,write" secret="secret" /&gt;
  &lt;/oauth:client-details-service&gt;
  </code></pre>
  
  <p>I just want my client to work without spring security. And when I need my protected resource I want to login only on provider side.</p>