How to authenticate against Artifactory with a HTTP/REST client?

You may need to pass the authorization header from your REST client to Artifactory. Below is an example of setting up an authentication using a “Basic Authentication” method, but you may consider using more secure authentication methods, such as HMAC(hash based message authentication), OAuth(open standard for authorization), or OAuth2(open standard for authorization version 2) for authentication. (You may refer to a third party solution such as The Restful Cookbook > I want users to login into my RESTful API so only they can see (protected) resources. What is the correct way to do this?)


<Basic Authentication>


The special token in the above header should be the bytes of the “userName:password” String you are trying to use encoded with Base64. This is the standard BASIC authorization header format.


For example, if my credentials are:

username=shay

password=password

 

I will need to encode the following with base64:

shay:password

Which will result in: c2hheTpwYXNzd29yZA==

 

And the final header that I should add to the request is:

Authorization: Basic c2hheTpwYXNzd29yZA==