I am using Angular and I am attempting to pass a bearer token through an OData source with a DevExtreme DXDataGrid, but I am facing authentication issues. The error message "Current user did not login to the application!" keeps appearing, indicating that it is failing to authenticate.
Interestingly, I can successfully make the call using Postman. Below is my DataSource definition:
constructor(
injector: Injector,
private _route: ActivatedRoute,
private _router: Router
) {
super(injector);
let authString = "Bearer " + getToken();
this.gridDataSource = {
store: {
type: 'odata',
key: 'Id',
keyType: "Int32",
version: 4,
url: 'http://localhost:21021/odata/Roles'
},
select: [
'Id',
'Name',
'DisplayName'
],
beforeSend: (e) => {
e.headers = {
"Content-Type": "application/json",
"Authorization": authString
}
}
}
}
View Postman request image here.
I suspect that there might be an issue with how I have formatted the before send header definition. Any assistance on this matter would be highly appreciated.