I try to call data JSON from URL, and the source need authentication bearer I create in codeigniter framework this is my reference link
and here is my code,
$.ajax({
url: "url",
method: "GET",
headers: {
'Token': Bearer +'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTgwMTg1MjA0LCJleHAiOjE1ODAxODg4MDR9.dG13Tv62YHgdH9SD1HKPCc_JSAVgqrJb70UlR-bqy4E'
},
contentType: 'application/json',
success: function(data) {
},
error: function (data, status, xhr) {
console.log(status);
console.log(xhr);
}
});
any help would be appreciated.
Bearershould be a the string "Bearer" - and usually you'd useAuthorizationas the header, but if the API requiresTokenthen that's fine - though, reading the documentation you linked to, but obviously haven't read, the header should beAuthorizationnotToken... and as stated theBeareris part of the header value, i.e. it's a literal stringAuthentication: 'Bearer "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6ImFkbWluIiwiaWF0IjoxNTgwMTg1MjA0LCJleHAiOjE1ODAxODg4MDR9.dG13Tv62YHgdH9SD1HKPCc_JSAVgqrJb70UlR-bqy4E"'Bearerinstead of the stringBearer- and perhaps the token part needs to be in"- but since your actual requirements only partially resemble the code you're basing it on, then you'll need to tweak those minutiae