I have an application that must connect to the AWS Cognito and check if the access token is valid or not.
If it's still a valid one then the request will be done successfully, otherwise the access token will be refreshed and the new access token will be returned with the request response.
I decided to create two interceptors: one for the request and the other one for the response.
Everything is doing fine at this point and i can get my new token and use it to resolve the request with no problem.
The problem is when i need to intercept the response and add the new token to the response and send it back to be refreshed in the frontend application.
I already tried everything (onPostHandler, onPreResponse) and i can't add a single element to the response.
I can modify all the response, but not add an element and keep the previous status code and the body.
I thought send a new response, but i need to find a way to get the previous status code and source, but i simply can't get them.
So, it would be awesome if you could help me with this problem.
Hi everyone.
I have an application that must connect to the AWS Cognito and check if the access token is valid or not. If it's still a valid one then the request will be done successfully, otherwise the access token will be refreshed and the new access token will be returned with the request response.
I decided to create two interceptors: one for the request and the other one for the response.
I can intercept the request by doing this:
Everything is doing fine at this point and i can get my new token and use it to resolve the request with no problem.
The problem is when i need to intercept the response and add the new token to the response and send it back to be refreshed in the frontend application.
I did it this way:
I already tried everything (onPostHandler, onPreResponse) and i can't add a single element to the response. I can modify all the response, but not add an element and keep the previous status code and the body.
I thought send a new response, but i need to find a way to get the previous status code and source, but i simply can't get them.
So, it would be awesome if you could help me with this problem.
Thanks in advance,
Fábio Medeiros