Search code examples
groovyhttpbuilder

What is the correct way of using ntlm authentication with RESTClient?


The follow code works fine but AuthPNames and AuthPolicy are marked as depreciated and I cannot find anything on what to replace it with.

import groovyx.net.http.RESTClient

def restClient = new RESTClient(config.server)

restClient.client.credentialsProvider.setCredentials(
   AuthScope.ANY, 
   new NTCredentials(
      config.authUsername, 
      config.authPassword, 
      config.authWorkstation, 
      config.authDomain)
)
restClient.client.params.setParameter(
   AuthPNames.TARGET_AUTH_PREF, 
   [AuthPolicy.NTLM]
)

Solution

  • You can find it in the docs: