javascripthtmlauthenticationgetbasic-authentication

How does one acquire Basic Auth credentials from JavaScript/HTML?


My webpage needs to pass on credentials delivered in a Basic Authentication header to a REST call (a GET in this case) which itself requires Basic Authentication. Essentially I just want to pass on the same basic auth header, since both the server and the target of the REST request use the same db to verify the username/password combo.

However, despite extensive googling, I just can't find a way to do that without bringing in some extra stuff like node.

I'd like to stick to pure JavaScript and HTML.


Solution

  • It is not possible to use client side JS to read the credentials used to load the currently viewed page.