title: basic auth http-builder-ng
body: <p>Basic Auth not working with http-builder-ng  - Authorization request is not passed by ng?</p>
  
  <p><strong>build.gradle</strong> </p>
  
  <pre><code>group 'org.vinay.rest'
  version '1.0-SNAPSHOT'
  
  apply plugin: 'groovy'
  apply plugin: 'java'
  
  sourceCompatibility = 1.8
  
  repositories {
      mavenCentral()
      jcenter()
  }
  
  dependencies {
      // https://mvnrepository.com/artifact/io.github.http-builder-ng/http-builder-ng-core
      testRuntime group: 'io.github.http-builder-ng', name: 'http-builder-ng-core', version: '0.17.0'
      testCompile group: 'junit', name: 'junit', version: '4.12'
      testCompile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4'
      testCompile group: 'ch.qos.logback', name: 'logback-classic', version:'1.0.13'
  }
  </code></pre>
  
  <p><strong>GetD2LUserBySourcedIdSpec.groovy</strong></p>
  
  <pre><code>import spock.lang.Specification
  import groovyx.net.http.HttpBuilder
  
  /**
   * Created by e5017581 on 11/07/2017.
   */
  class GetD2LUserBySourcedIdSpec  extends Specification {
     def "test get /users call with d2lSourced Id"() {
         given:
  
         def httpClient = HttpBuilder.configure {
             request.uri = 'http://esbvucmv5.vu.edu.au/D2L/2.0'
             //request.headers['Authorization'] = 'Basic ZDJscnM6MTRkMmxycw=='
             //request.headers['Content-Type'] = "application/json"
             request.auth.basic'd2lrs', '14d2lrs'
  
         }
         when:
         def user = httpClient.get {
             //request.auth.basic 'd2lrs', '14d2lrs'
             //request.headers['Authorization'] = 'Basic ZDJscnM6MTRkMmxycw=='
             request.uri.path = '/users/'
             request.uri.query = [sourcedId: 's4504565']
         }
         then:
         println user.dump()
         null != user
     }
  }
  </code></pre>
  
  <p><strong>http-logs:</strong></p>
  
  <pre><code>com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 "GetD2LUserBySourcedIdSpec,test get /users call with d2lSourced Id"
  15:41:36,714 |-INFO in ch.qos.logback.classic.LoggerContext[default] - Found resource [logback.groovy] at [file:/C:/Users/e5017581/IdeaProjects/http-builder-ng2/build/resources/test/logback.groovy]
  15:41:36,935 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@6d07a63d - Added status listener of type [ch.qos.logback.core.status.OnConsoleStatusListener]
  15:41:36,946 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@6d07a63d - About to instantiate appender of type [ch.qos.logback.core.ConsoleAppender]
  15:41:36,947 |-INFO in ch.qos.logback.classic.gaffer.ConfigurationDelegate@6d07a63d - Naming appender as [CONSOLE]
  15:41:37.100 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Request-Header: Accept-Encoding -&gt; [gzip, deflate]
  15:41:37.306 [main] DEBUG g.net.http.JavaHttpBuilder.content - Response-Body: null
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Date -&gt; Tue, 11 Jul 2017 05:41:37 GMT
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Content-Type -&gt; text/plain
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Content-Length -&gt; 42
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Connection -&gt; keep-alive
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Server -&gt; Mule/SNAPSHOT
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: WWW-Authenticate -&gt; Basic realm="realm"
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: http.status -&gt; 401
  15:41:37.307 [main] DEBUG g.net.http.JavaHttpBuilder.headers - Response-Header: Set-Cookie -&gt; VUpersist=rd2480o00000000000000000000ffff0a4c0016o80; path=/; Httponly
  
  groovyx.net.http.HttpException: Unauthorized
  at groovyx.net.http.NativeHandlers.failure(NativeHandlers.java:69)
  at groovy.lang.Closure.call(Closure.java:423)
  at groovyx.net.http.fn.ClosureBiFunction.apply(ClosureBiFunction.java:45)
  at groovyx.net.http.HttpBuilder$ResponseHandlerFunction.apply(HttpBuilder.java:1834)
  at groovyx.net.http.JavaHttpBuilder$Action.lambda$execute$2(JavaHttpBuilder.java:157)
  at groovyx.net.http.JavaHttpBuilder$ThreadLocalAuth.with(JavaHttpBuilder.java:320)
  at groovyx.net.http.JavaHttpBuilder$Action.execute(JavaHttpBuilder.java:111)
  at groovyx.net.http.JavaHttpBuilder.createAndExecute(JavaHttpBuilder.java:362)
  at groovyx.net.http.JavaHttpBuilder.doGet(JavaHttpBuilder.java:369)
  at groovyx.net.http.HttpObjectConfigImpl.nullInterceptor(HttpObjectConfigImpl.java:45)
  at groovyx.net.http.HttpBuilder.get(HttpBuilder.java:360)
  at groovyx.net.http.HttpBuilder.get(HttpBuilder.java:1311)
  at GetD2LUserBySourcedIdSpec.test get /users call with d2lSourced Id(GetD2LUserBySourcedIdSpec.groovy:19)
  
  
  Process finished with exit code -1
  </code></pre>