Trying to use 'Postman' and having trouble setting Basic access authentication Headers

后端 未结 4 776
渐次进展
渐次进展 2020-12-13 19:29

I have an API endpoint that I am trying to test with the google app: \'Postman\'. I need to set the headers which use \'Basic authentication\'. I am not sure what should go

4条回答
  •  星月不相逢
    2020-12-13 19:38

    Looks like you are facing trouble in getting the base64 value. Well you can make use of in-built function in Javscript as below.

    Simply run below code in any JS runtime, (Simplest would be - open console tab in chrome developer tool)

    "username:password!" // Here I used basic Auth string format
    
    // Encode the plain string to base64
    btoa("username:password!"); // output: "dXNlcm5hbWU6cGFzc3dvcmQh"
    
    
    // Decode the base64 to plain string
    atob("dXNlcm5hbWU6cGFzc3dvcmQh"); // output: "username:password!"
    

提交回复
热议问题