CustomAdaptor extending ODataV4Adaptor
Hi,
I am trying to create a customadapter simply to override ODataV4Adaptor's BeforeSend() to check if token is still valid before sending, i want to keep all other functionality in adaptor as is.
We already have an httpinterceptor for our applications but its not working with calls through the SfDataManager/ODataV4Adaptor..
My goal is to do this check with either a customadaptor or some kind of httpinterceptor for the adaptor wich i then can use in all of our applications.
But when im trying to use the customadapter i encountered some errors for example not being able to cast customadaptor to DataAdaptor.
1. Is it possible to create a CustomAdaptor by extending the ODataV4Adaptor or is it only possible with DataAdaptor?
2. If it is possible, how would i handle the ctor requiring DataManager, is it OK to inject? Is there any examples?
3. If it is NOT possible, do you have suggestions of another way i can solve my problem?
Regards,
Jesper
Using:
Syncfusion.Blazor 18.1.0.52
AspNetCore 3.1.4
AspNetCore.OData 7.4.0
SIGN IN To post a reply.
1 Reply
1 reply marked as answer
VN
Vignesh Natarajan
Syncfusion Team
August 17, 2020 07:28 AM UTC
Hi Jesper,
Thanks for contacting Syncfusion support.
Query: “I am trying to create a customadapter simply to override ODataV4Adaptor's BeforeSend() to check if token is still valid before sending, && If it is NOT possible, do you have suggestions of another way i can solve my problem?”
No, CustomAdaptor cannot be extended using ODataV4Adaptor, it will extend only DataAdaptor. We have analyzed your query and we suspect that you want to send your Authentication Token to OData service to authorize the certain action. We suggest you to achieve your requirement by sending the Authentication token as header using Header property of SfDataManager.
Refer the below code example
|
<SfGrid TValue="Order" AllowPaging="true">
<GridColumns>
. . . . . . .. .
</GridColumns>
</SfGrid>
@code{
private IDictionary<string, string> HeaderData = new Dictionary<string, string>();
protected override void OnInitialized()
{
HeaderData.Add("Bearer", "{your_auth_token}");
}
public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
} |
Refer our UG documentation for your reference
Please get back to us if you have further queries.
Regards,
Vignesh Natarajan
Marked as answer
SIGN IN To post a reply.