Announcement Announcement Module
No announcement yet.
No OAuth 2 security context has been established. Unable to access resource... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • No OAuth 2 security context has been established. Unable to access resource...

    When I attempt to use a oauth rest template, I get:

    No OAuth 2 security context has been established. Unable to access resource...

    At: uth2ClientHttpRequestFactory.createRequest(OAuth2C or.createRequest(
    org.springframework.web.client.RestTemplate.doExec ute(
    org.springframework.web.client.RestTemplate.execut e(
    org.springframework.web.client.RestTemplate.getFor Entity(

    I've looked through the archives & found tried some of the fixes for what is the identical issue, but they haven't worked for me, most specifically the custom filter mentioned in the documents and several threads. According to my debug logs on the provider side, no authentication is ever attempted.

    The seemingly relevant configuration in what is a very simple roo web app set up to test only oauth2 client connectivity looks like:

    <http access-denied-page="/spring_security_login?authorization_error=true" use-expressions="true"
            <intercept-url pattern="/**" access="isAuthenticated()" />
            <logout logout-url="/resources/j_spring_security_logout"/>        
    		<anonymous />
    		<custom-filter ref="oauth2ClientFilter" after="EXCEPTION_TRANSLATION_FILTER" />
    <oauth:client id="oauth2ClientFilter" redirect-on-error="${redirectOnError:true}" />
    <oauth:resource id="readWriteClient" type="authorization_code" client-id="CredentialServicesSite" client-secret="secret"
    		access-token-uri="${accessTokenUri}" user-authorization-uri="${userAuthorizationUri}" scope="read,write" />
    <bean id="sigkatService" class="">
    	<property name="sigkatRestTemplate">
    		<bean class="">
    			<constructor-arg ref="readWriteClient" />
    And then the controller code, which is:

    public String post(ModelMap modelMap, HttpServletRequest request, HttpServletResponse response) {
            String body="Hello redirecturi<p>";
        	modelMap.addAttribute("body", "Hello redirecturi");
        	return "redirecturi/index";
    Via other tests, everything seems fine on the provider end, but in any event, it isn't even getting that far.

    FWIW, I've tried it with both the redirect on error set to both true/false...

    Any help on this would be appreciated.

    Jay Roberts
    Last edited by robatsu; Mar 18th, 2012, 06:10 PM.

  • #2
    Ok, never mind. This thread had the fix.