I have this React App which has back end as Spring Boot java application. Its login flow requires to redirect from App to third party servlet, and then this servlet calls our backend API with AUTH code, which after validation in backend must be redirected to our react App, along with Auth code. Now problem is, while I am able to redirect response to my react app, how can I access http, ResponseEntity in react App?
@GetMapping
public ResponseEntity<String> generateAuthToken(
@RequestParam("code") String authCode,
@RequestParam("state") String state,
HttpServletResponse httpServletResponse
) {
log.debug("Found token {}, and state {}", authCode, state);
String authToken = getAuthToken(authCode);
httpServletResponse.setHeader("Location", "http://localhost:3000/MainMenu");
httpServletResponse.setStatus(302);
return new ResponseEntity<String>(authToken , HttpStatus.MOVED_PERMANENTLY);
}
How can I access this authToken in sent in ReponseEntity in our ReactApp's MainMenu component. User clicks login button on Front end App (in react) -> App redirect user to a third party servlet to gather credentials -> Servlet authenticates user, generate AUTHZ code and call a rest end point on back end -> Back end point(Spring Boot application) process AUTHZ code and generates String access token and redirect response to Front end react App with this access token. I am able to redirect to Front end app using HttpServletResponse redirect, how to send access token to react app.