title: DocusignAPI Authentication with PHP: "Integrator key was not specified"
body: <p>I'm working on my first DocuSign API implementation and I'm having trouble authenticating to the REST API.</p>
  
  <p>Following the API docs, I can authenticate successfully through using curl on the command line:</p>
  
  <pre><code>$ curl --request GET 'https://demo.docusign.net/restapi/v2/login_information' --header 'Content-Type:application/json' --header 'Accept:application/json' --header 'X-DocuSign-Authentication:{"&lt;redacted&gt;", "Password": "&lt;redacted&gt;", "IntegratorKey": "&lt;redacted&gt;"}'
  {
    "loginAccounts": [
      {
        "name": "&lt;redacted&gt;",
        "accountId": "&lt;redacted&gt;",
        "baseUrl": "https://demo.docusign.net/restapi/v2/accounts/&lt;redacted&gt;",
        "isDefault": "true",
        "userName": "&lt;redacted&gt;",
        "userId": "&lt;redacted&gt;",
        "email": "&lt;redacted&gt;",
        "siteDescription": ""
      }
    ]
  </code></pre>
  
  <p>However, when trying to authenticate using an HTTP request through PHP, I receive a '401 Unauthorized' response, with the body:</p>
  
  <pre><code>'{
    "errorCode": "PARTNER_AUTHENTICATION_FAILED",
    "message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
  }'
  </code></pre>
  
  <p>I'm pretty sure I'm setting an IntegratorKey header. My PHP code looks like:</p>
  
  <pre><code>$request = new \http\Client\Request('GET', $url, $this-&gt;getHeaders());
  $client = new \http\Client();
  $client-&gt;enqueue($request)-&gt;send();
  $response = $client-&gt;getResponse();
  </code></pre>
  
  <p>I'm using the pecl/http-v2 HTTP library (docs at: <a href="http://devel-m6w6.rhcloud.com/mdref/http" rel="nofollow">http://devel-m6w6.rhcloud.com/mdref/http</a> )</p>
  
  <p>$url evals to:  <code>'https://demo.docusign.net/restapi/v2/login_information'</code></p>
  
  <p>The header array looks like:</p>
  
  <pre><code>array (size=3)
      0 =&gt; string 'X-DocuSign-Authentication: {"Username": "&lt;redacted&gt;", "Password":  "&lt;redacted&gt;", "IntegratorKey": "&lt;redacted&gt;"}' (length=155)
      1 =&gt; string 'Content-Type: application/json' (length=30)
      2 =&gt; string 'Accept: application/json' (length=24)
  </code></pre>
  
  <p>It appears the API key isn't being received, even though I can see the proper headers are being sent. Any ideas what I'm doing wrong here? Thanks for your help!</p>
  
  <p><em>Edit:</em> Fixed a missing double-quote around the password field in the authentication header. I had accidentally removed it while redacting the password. The authentication header matches character-for-character with the header used in the (working) 'curl' command.</p>