We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

OdataV4 connector and JWT bearer token ( simple example?)

Hello,

Now I have made working Odata WebApi with asp net core 3.1
that seems to work with BlazorDatagrid wirh OdataV4 connector

What is the correct and simple way add JWT bearer token to OdataV4 connector as I
implement [Authorize]  to controllers on  API project?

So controller still can read/write data from API


Best regards,
Jukka




3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team June 9, 2020 11:55 AM UTC

Hi Jukka,  

Thanks for contacting Syncfusion support. 

We understood that you want to Authenticate your OData WebAPI using the DataManager. We suggest you to achieve your requirement by passing the Authentication token to OData WebAPI as a Header using Headers property in DataManager. Refer the below code example. 

<SfGrid TValue="Order" AllowFiltering="true" AllowSorting="true" AllowPaging="true" Toolbar="@new List<string> { "Search" })">  
   <SfDataManager Headers=@HeaderData Url="@OdataUrl" Adaptor="Adaptors.ODataV4Adaptor"></SfDataManager> 
    ... 
</SfGrid>
  
@code{  
    private IDictionary<stringstring> HeaderData = new Dictionary<stringstring>();  
  
    protected override void OnInitialized()  
    {  
        HeaderData.Add("Bearer""{your_auth_token}");  
    }  
  
    public class Order  
    {  
        ... 
    }  
}  
 

Refer our UG documentation for your reference  

Please get back to us if you have further queries  

Regards, 
Renjith Singh Rajendran 


Marked as answer

AS ashimaz June 11, 2020 08:43 PM UTC

When using blazor 18.1.55 client side grid with Adaptors.UrlAdaptor on authorized web, please add header as follows.

HeaderData.Add("Authorization", "bearer " + "your_auth_token");


VN Vignesh Natarajan Syncfusion Team June 12, 2020 11:14 AM UTC

Hi Ashimaz,  

Thanks for your suggestion.  

Kindly get back to us if you have any other queries.   

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon