The situation is that there is a backend Web API which requires the front-end page caller provides the authorization data (username and password). And I need to write a front-end web client code to be the Web API caller. (It's a general usage no matter what which language is)
The Web API has only provides the Basic Authorization, no other ways to do it like token or something else.
If I directly wrote the username and password as plain text on the client side code, the user could see these plain text in the source code from browser easily.
I wonder what is the best practice to handle these authorization data in front-end client side page?
Thanks
It would be impossible for you to hide plaintext details leaving a clients machine as there are many places they would be able to intercept it. One solution would be to set up a server in the middle which acts as a proxy between your client and the API. You can have whatever authentication you like on the middle server and you can store your details there safely.