RADAR-base / RADAR-RestApi

RESTful interface to access near real-time data
Apache License 2.0
2 stars 0 forks source link

TOKEN cannot be generated: org.radarcns.exception.TokenException: Forbidden: Could not verify the provided CSRF token because your session was not found. #59

Closed nivemaham closed 6 years ago

nivemaham commented 6 years ago

I am on update-build branch and rolling my head on this for last 3 days. I am trying to connect to actual ManagementPortal and hotstorage instances running on localhost. I have the config files configured properly. When i start the application i keep getting

2017-12-29 13:50:53 UTC [.1] WARN  - TOKEN cannot be generated: org.radarcns.exception.TokenException: Forbidden: Could not verify the provided CSRF token because your session was not found. [org.radarcns.listener.managementportal.TokenManagerListener:79] 
2017-12-29 13:50:53 UTC [.1] INFO  - Authentication filter initialized [org.radarcns.security.filter.AuthenticationFilter:37] 

Specifically this happens when the TokenContextListener is trying to initiate the context with an access token using OAuth2Clientin TokenContextListener.

 token = client.getAccessToken();

and in OAuth2Client

private void getNewToken() throws TokenException {
  // prepare request
  try (Response response = getHttpClient().newCall(updatedRequest).execute()) {
            currentToken = OAuth2AccessTokenDetails.getObject(response);
  }
}

However CSRF is disabled on MP side AFAIK. It works when issue the same request using Postman or Curl, but not using OAuth2Client.

From my preliminary investigation, the only difference i see from curl response and response from OAuth2Client.java is the later has additional response header Set-Cookie: JSESSIONID=<some token>.

nivemaham commented 6 years ago

Not relevant anymore. Issue was due to wrongly formatted URL. :confused: