Despite the COVID-19 outbreak, our team continues operating at full speed. We are always here to support and answer all your questions.

Feel free to reach out by filling this quick form.

Fill the form
Get Free Trial

Http request error handling and auth token auto refresh

Re-Open
Will Liu asked on September 1, 2020

Hi,
 
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. 
 
Thanks,
Will
 

9 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 3, 2020

Hello,
 
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.
 
Best regards,
Illia

Public
Will Liu September 4, 2020

Hi Illia,

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. 
 
 

Thanks,
Will

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 4, 2020

Hello,
 
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.
 
Best regards,
Illia

Public
Will Liu September 6, 2020

Hi Illia,
 
Thank you so much! I’m looking forward to the results.
 
Regards,
Will

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 6, 2020

Hello, Will,
 
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.
The 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.
 
Best regards,
Illia

Public
Will Liu October 13, 2020

Thanks a lot! I’ll give it a try.

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster October 19, 2020

Hello, Will,
 
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.
 
Kind regards,
Illia

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster 2 days ago

Hello, Will,
 
Our team is wondering whether you had some time to test the introduced feature.
 
We are looking forward to your feedback.
 
Best regards,
Illia

Public
Will Liu 1 day ago

Hi Illia ,
 
The `unauthorizederror` is working as expected. I can now refresh my token and tell flexmonster to resend the request when token expires.
 
Thanks & Regards,
Will

Please login or Register to Submit Answer