DataManager Windows Authentication

Hi,

how can I use a WebAPI which needs Windows Authentication as Datasource for a Grid thru DataManager in a Blazor Server App?

If I use a WebAPI which needs no Authentication the data is visible in the grid, but for other reasons I need to authenticate with the WebAPI.

The Client can successfully authenticate with the Blazor Server App, but how can I use this Credentials to authenticate to the WebAPI thru DataManager?

Thanks in advance for your help!

Stephan

1 Reply 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team June 8, 2020 04:52 AM UTC

 
Thanks for contacting Syncfusion support. 
 
Query: “The Client can successfully authenticate with the Blazor Server App, but how can I use this Credentials to authenticate to the WebAPI thru DataManager? 
 
From your query we understand that you want to Authenticate your WebAPI using the DataManager. We suggest you to achieve your requirement by passing the Authentication token to WebAPI as a Header using Headers property in DataManager. Refer the below code example. 
 
 
<SfGrid TValue="Order" AllowPaging="true">  
    <SfDataManager Headers=@HeaderData Url="https://ej2services.syncfusion.com/production/web-services/api/Orders" Adaptor="Adaptors.WebApiAdaptor"></SfDataManager>  
    <GridColumns>  
. . . . . . .. .  
    </GridColumns>  
</SfGrid>  
  
@code{  
    private IDictionary<stringstring> HeaderData = new Dictionary<stringstring>();  
  
    protected override void OnInitialized()  
    {  
        HeaderData.Add("Bearer""{your_auth_token}");  
    }  
  
    public class Order  
    {  
        public int? OrderID { getset; }  
        public string CustomerID { getset; }  
        public DateTime? OrderDate { getset; }  
        public double? Freight { getset; }  
    }  
}  
 
Refer our UG documentation for your reference  
 
 
Kindly get back to us if you have further queries  
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon