import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import javax.ws.rs.client.Client; import javax.ws.rs.client.ClientBuilder; HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("myUser", "myPassword"); Client client = ClientBuilder.newClient(); client.register(feature); // Applied to all requests from this client Use code with caution. Key Considerations org.glassfish.jersey.core.jersey-client 3.1.7
: Use HttpAuthenticationFeature.basic(user, pass) . org.glassfish.jersey.client.authentication jar download
For automated builds, add the following to your configuration file. Note that jersey-client 2.x is the most widely compatible for many legacy projects, while 3.x is the modern standard for Jakarta EE. import org
Useful for finding JARs with all their dependencies pre-packaged. For example, Jersey Client 3.0.4 is available here. Note that jersey-client 2
Once the JAR is in your classpath, you can use the authentication package to secure your REST calls. A common use case is :
If you are not using a build tool, you can manually download the jersey-client JAR from the following repositories: