title: ADAL node js username password authentication
body: <p>I am using the adal node js library 1.22, and trying to authenticate a user with username and password. I am getting a "unable to get local issuer certificate" error. The user is federated and the error happens on realm discovery.</p>
  
  <pre><code> var context = new AuthenticationContext(authorityUrl);
  
  context.acquireTokenWithUsernamePassword(resource, sampleParameters.username, sampleParameters.password, sampleParameters.clientId, function(err, tokenResponse) {
    if (err) {
      console.log('well that didn\'t work: ' + err.stack);
    } else {
      console.log(tokenResponse);
    }
  });
  </code></pre>
  
  <p>The error stack:</p>
  
  <pre><code>Stack:
  Error: unable to get local issuer certificate
      at Error (native)
      at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1092:38)
      at emitNone (events.js:86:13)
      at TLSSocket.emit (events.js:185:7)
      at TLSSocket._finishInit (_tls_wrap.js:610:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
  { Error: unable to get local issuer certificate
      at Error (native)
      at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1092:38)
      at emitNone (events.js:86:13)
      at TLSSocket.emit (events.js:185:7)
      at TLSSocket._finishInit (_tls_wrap.js:610:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }
  Wed, 14 Jun 2017 08:44:17 GMT:079c7b70-6ae1-461c-b433-cc3fe0c22783 - TokenRequest: VERBOSE: getTokenFunc returned with err
  well that didn't work: Error: unable to get local issuer certificate
      at Error (native)
      at TLSSocket.&lt;anonymous&gt; (_tls_wrap.js:1092:38)
      at emitNone (events.js:86:13)
      at TLSSocket.emit (events.js:185:7)
      at TLSSocket._finishInit (_tls_wrap.js:610:8)
      at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
  </code></pre>
  
  <p>Can you please advise on what certificate i am missing and where to find it. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>after digging through the code i found that commenting out the global agent.ca part of the code resolved this issue and the library was able to perform a few steps after that, but it had a problem returning the token response from ADFS. </p>
  
  <p>The log: </p>
  
  <pre><code>    Wed, 14 Jun 2017 10:39:39 GMT:425e3117-a495-4f8e-8a12-e7e64dd0e37b - OAuth2Client: INFO: Get TokenServer returned this correlationId: 425e3117-a495-4f8e-8a12-e7e64dd0e37b
  Wed, 14 Jun 2017 10:39:39 GMT:425e3117-a495-4f8e-8a12-e7e64dd0e37b - OAuth2Client: ERROR: Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.\r\nTrace ID: aadf1560-18ec-46f9-83b6-5932c2131200\r\nCorrelation ID: 425e3117-a495-4f8e-8a12-e7e64dd0e37b\r\nTimestamp: 2017-06-14 10:39:41Z","error_codes":[70002],"timestamp":"2017-06-14 10:39:41Z","trace_id":"aadf1560-18ec-46f9-83b6-5932c2131200","correlation_id":"425e3117-a495-4f8e-8a12-e7e64dd0e37b"}
  </code></pre>
  
  <p>Is there any configuration that i forgot,</p>
  
  <pre><code>if (!parametersFile) {
    sampleParameters = {
      tenant : 'tenant.onmicrosoft.com',
      authorityHostUrl : 'https://login.microsoftonline.com',
      clientId : 'aa461028-1fgf-46e5-ab9b-5adca324febc',
      username : 'user@domain.net',
      password : 'lamepassword'
    };
  }
  
  var authorityUrl = sampleParameters.authorityHostUrl + '/' + sampleParameters.tenant;
  
  var resource = '00000002-0000-0000-c000-000000000000';
  </code></pre>