basic authorization command for curl

后端 未结 5 1909
小蘑菇
小蘑菇 2021-02-04 23:33

How do I set up the basic authorization using 64 encoded credentials ? I tried below the two commands but of no use , please suggest.

curl -i -H \'Accept:applic         


        
5条回答
  •  别跟我提以往
    2021-02-05 00:30

    One way, provide --user flag as part of curl, as follows:

    curl --user username:password http://example.com
    

    Another way is to get Base64 encoded token of "username:password" from any online website like - https://www.base64encode.org/ and pass it as Authorization header of curl as follows:

    curl -i -H 'Authorization:Basic dXNlcm5hbWU6cGFzc3dvcmQ=' http://localhost:8080/
    

    Here, dXNlcm5hbWU6cGFzc3dvcmQ= is Base64 encoded token of username:password.

提交回复
热议问题