Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authorization Bearer Token Header in Javascript

I am trying to create a header for an authorization bearer token that I generated from the API's side. I am using CORS-anywhere to call the API and get the data through JSON. I was wondering, what is the correct format for the authorization bearer token header?

like image 383
Yashvardhan Khaitan Avatar asked Sep 18 '25 03:09

Yashvardhan Khaitan


1 Answers

Without any more information to go off of, typically an Authorization header that uses a bearer token should look like the following:

Authorization: Bearer mF_9.B5f-4.1JqM

In javascript, typically it involves setting the Authorization property of a headers object:

// headers you pass to a http request
let headers = {
   'Authorization': 'Bearer ' + token
};

Usually a http request library will taken in a parameter for headers somewhere that you would pass this to.

Is there something more specific you want to know?

like image 166
dwosk Avatar answered Sep 19 '25 17:09

dwosk