We have a question regarding Http request errors with flexmonster. We have a problem when our short lived Authentication token expires, any request using this token will result in a 401 and errors will be shown to the user.
What we would like to be able to do, is when we get a 401, we automatically kick off a token refresh, then after that is complete, we send the same request, with the new token, not even letting our users know this happening.
We’ve tried queryerror, olapstructureerror, and dataerror event handlers, but they don’t really help in this scenario. The first problem is these errors don’t give you details so you won’t be able to check and see if the error is caused by 401 http response or not. Another problem is, it may not be possible to re-send the request or replay the action which emits the network request after token refreshed.
I was wondering if there are any solutions to my problem.
Thank you for writing to us.
Our team wants to confirm that it is not possible to check the specific status code received from the server using the capabilities of Flexmonster.
Instead, we suggest checking the authorization token before Flexmonster makes an attempt to establish the connection. It means an additional request to the server needs to be performed. Such a request would be responsible for checking the token before establishing the connection itself.
After the request, keep or update the token depending on the received status code.
Finally, connect Flexmonster to your data source using the already validated token.
Please let us know if the provided approach fits your case.
We are looking forward to hearing from you.
Thanks for your reply.
Unfortunately this approach won’t cover all our cases.
Firstly, we will provide valid auth token for data source headers, which works perfectly. The case is, our token will only be valid for a short period, let’s say 30 mins. If a user stays on the page for 31 mins and then performs an action within Flexmonster then the request sent from Flexmonster will raise 401 unauthorized errors. We wanted to call our API to auto renew the auth token once this happens.
If Flexmonster can provide some sort of capability to replace the internal HTTP request sender with a customized HTTP request engine, that’ll be really helpful. I found the API customizeAPIRequest(customizeAPIRequestFunction: Function) but this only allows you to modify requests before sending, not actually to customize the sending process.
Thank you for your feedback and for providing details.
We want to confirm that current Flexmonster functionality doesn’t cover the described scenario.
Our team will investigate possible solutions and provide you with results ETA Oct 05.
Please contact us in case any other questions arise.
Thank you so much! I’m looking forward to the results.
We are happy to let you know that for SSAS Accelerator, an event
unauthorizederror was added. It can be used to refresh the authorization headers.
It is triggered when the Accelerator sends the
401 Unauthorized error in response to the Flexmonster request.
callbackHandler function is passed to the handler. It can be used to re-send the request to the Accelerator with new request headers.
Please see our documentation to learn more about the
unauthorizederror event and the way to use it.
This is provided in the 2.8.17 version of Flexmonster.
You are welcome to update the component.
Here is our updating to the latest version tutorial for guidance.
Please let us know if it works for you.
Thanks a lot! I’ll give it a try.
We want to take an interest in whether you had some time to test the recently provided feature.
Our team is looking forward to hearing from you.
Our team is wondering whether you had some time to test the introduced feature.
We are looking forward to your feedback.
Hi Illia ,
unauthorizederror` is working as expected. I can now refresh my token and tell flexmonster to resend the request when token expires.
Thanks & Regards,
Is it possible to have the same feature also for the “api” datasource type?
Thank you for your question.
Our team could add the
unauthorizederror event for the custom data source API in one of the upcoming minor releases. We will notify you as soon as it is released.
The unauthorizederror event would work the same way as for the
"microsoft analysis services" data source type.
Please feel free to reach out if any questions arise in the meantime.
Also, our team would like to kindly take an interest in which data source type you are using.
As far as we know, you have been using the JSON approach. Could you please let us know if you are still using JSON or switched to the custom data source API approach?
Thank you, and looking forward to your response.
Hi Vera, thanks for your help, I will wait for the next minor release.
I am using both types, custom and json datasource.
We are happy to announce that the
unauthorizederror event was added for the custom data source API.
This is available in the latest version of Flexmonster.
You are welcome to update the component. Here is our updating to the latest version guide for assistance.
Please let us know if the update works fine for you.
Looking forward to your feedback.
How are you?
Just checking in to ask if you’ve had a chance to try out the update.
Please let us know if everything works fine for you.
Looking forward to your response.
Hope you’re having a great day!
Our team is wondering if the
unauthorizederror event for custom data source API worked for you.
Please let us know if everything worked.