darrachequesne / spring-data-jpa-datatables

Spring Data JPA extension to work with the great jQuery plugin DataTables (https://datatables.net/)
Apache License 2.0
447 stars 173 forks source link

Request resource from Oauth2 resource server #75

Closed vanrin closed 6 years ago

vanrin commented 6 years ago

How to request resource from Oauth2 resource server? I have tried ajax: '/api/errorlog/all', serverSide: true, processing: true, And give following error {error: "unauthorized", error_description: "Full authentication is required to access this resource"} error : "unauthorized" error_description : "Full authentication is required to access this resource"

Note : I use spring boot with thymeleaf and try to request after authenticated.

darrachequesne commented 6 years ago

I think you should be able to achieve what you want with the ajax option. Something like:

var table = $('table#sample').DataTable({
  ajax: {
    beforeSend: (xhr) => xhr.setRequestHeader('Authorization', 'Bearer <token>')
  }
}
vanrin commented 6 years ago

thanks