CustomProxy and best place to catch/intercept error, specifically when JWT token expires. #3653
-
I have a Winforms application calling ASPNet Core hosted DataPortal with a mixed authentication model (AD authentication and good old-fashioned manual logins), and all working fine. Am using a CustomProxy class, but I need/want a simple re-try pattern if any of my dataportal calls fail with an unauthorized exception when the token expires. Where's the best place to centralize a check? I'm looking at the custom proxy class and wondering if I override the base Fetch, Delete, etc methods.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I think that is correct.
Rocky
Get Outlook for Android<https://aka.ms/AAb9ysg>
…________________________________
From: richardbartley ***@***.***>
Sent: Monday, January 15, 2024 9:36:30 AM
To: MarimerLLC/csla ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [MarimerLLC/csla] CustomProxy and best place to catch/intercept error, specifically when JWT token expires. (Discussion #3653)
I have a Winforms application calling ASPNet Core hosted DataPortal with AD authentication, and all working fine.
Am using a CustomProxy class, but I need/want a simple re-try pattern if any of my dataportal calls fail with an unauthorized exception when the token expires.
Where's the best place to centralize a check?
I'm looking at the custom proxy class and wondering if I override the base Fetch, Delete, etc methods.
public class CustomHttpProxy : HttpProxy
{
private readonly string _jwtToken;
public CustomHttpProxy(Csla.ApplicationContext applicationContext, HttpClient httpClient, HttpProxyOptions options, string jwtToken)
: base(applicationContext, httpClient, options)
{
_jwtToken = jwtToken;
}
public override Task<DataPortalResult> Fetch(Type objectType, object criteria, DataPortalContext context, bool isSync)
{
**// some retry logic here if token expired?????**
return base.Fetch(objectType, criteria, context, isSync);
}
—
Reply to this email directly, view it on GitHub<#3653>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AARZTTWXRYASHECRK7ZWNJLYOVLI5AVCNFSM6AAAAABB3RNKEGVHI2DSMVQWIX3LMV43ERDJONRXK43TNFXW4OZWGA3TQMZUGM>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Another way would be to implement a |
Beta Was this translation helpful? Give feedback.
Another way would be to implement a
DelegatingHandler
and configure the the defaultHttpClient
(configured viaservices.AddHttpClient()
iirc) to use it. So it's automatically used for everyHttpClient
request made by the defaultHttpClient
.