Hello Gain Lee,
Basic Authentication is an often used authentication method with API's it makes use of an username and password and this username and password are merged into the Authorization header and base64 encoded.
So for you understanding you can use for example postman to see what happens with this authentication method in your request.
Encoded is this:
Hope this clears it a bit,
Good luck!
And this is what Chat GPT has to say about it:
In Basic Authentication, the process of encoding the credentials (username and password) involves the following steps:
Combine the username and password: Join the username and password into a single string with a colon (:
) between them. For example, if the username is user
and the password is pass
, you create the string
user:pass
Base64 encode the combined string: Encode the resulting string from the first step using Base64 encoding. Base64 encoding is a way of converting binary data into an ASCII string format by translating it into a radix-64 representation. Using the user:pass
example, the encoded string would be:
dXNlcjpwYXNz
Use the encoded string in the HTTP request: The Base64 encoded string is then used as part of the HTTP Authorization header. The header will look something like this:
makefileAuthorization: Basic dXNlcjpwYXNz
Example in Steps
Let's go through the example step by step:
Combine username and password:
makefileuser:pass
Base64 encode the combined string:
dXNlcjpwYXNz
Construct the HTTP Authorization header:
makefileAuthorization: Basic dXNlcjpwYXNz
When a client sends an HTTP request with this header, the server will decode the Base64 string to retrieve the original user:pass
credentials and verify them.
Why Use Base64 Encoding?
Security Note
While Base64 encoding is used for encoding the credentials, it is not a secure encryption method. The encoded credentials can be easily decoded. Therefore, Basic Authentication should always be used over a secure HTTPS connection to prevent exposure of credentials.