Skip to content Skip to sidebar Skip to footer

Sending Authorization Token Bearer Through Javascript

I'm trying to send a Authorization Token Bearer through Javascript to a REST Endpoint, so i doing in this way: $.ajax( { url: 'http://localhost:8080/resourceserver/protected-no

Solution 1:

You can use headers key to add headers

$.ajax({
   url: 'http://localhost:8080/resourceserver/protected-no-scope',
   type: 'GET',
   contentType: 'application/json'headers: {
      'Authorization': 'Bearer <token>'
   },
   success: function (result) {
       // CallBack(result);
   },
   error: function (error) {

   }
});

You need to enable CORS on backend

https://stackoverflow.com/a/32320294/5567387

Post a Comment for "Sending Authorization Token Bearer Through Javascript"