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:application/json' Authorization:Basic <username:password> http://example.com curl -i -H 'Accept:application/json' Authorization:Basic.base64_encode(username:password) http://example.com
To send basic auth credentials with Curl, use the "-u login: password" command-line option. Curl automatically converts the login: password pair into a Base64-encoded string and adds the "Authorization: Basic [token]" header to the request.
To generate an access token: Replace {AUTH CODE QUERY PARAMETER} with the auth code you copied from the previous step in the above cURL request. Replace {CLIENT ID} in the above request with the Client ID from your Oauth client. Replace {CLIENT SECRET} in the above request with the Client Secret from your Oauth client.
We can do HTTP basic authentication URL with @ in password. We have to pass the credentials appended with the URL. The username and password must be added with the format − https://username:password@URL.
How do I set up the basic authorization?
All you need to do is use -u, --user USER[:PASSWORD]
. Behind the scenes curl
builds the Authorization
header with base64 encoded credentials for you.
Example:
curl -u username:password -i -H 'Accept:application/json' http://example.com
Use the -H
header again before the Authorization:Basic things. So it will be
curl -i \ -H 'Accept:application/json' \ -H 'Authorization:Basic BASE64_string' \ http://example.com
Here, BASE64_string
= Base64 of username:password
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With