普通网友
2015-01-06 21:48
浏览 36
已采纳

使用PHP进行DocusignAPI身份验证:“未指定集成器密钥”

I'm working on my first DocuSign API implementation and I'm having trouble authenticating to the REST API.

Following the API docs, I can authenticate successfully through using curl on the command line:

$ curl --request GET 'https://demo.docusign.net/restapi/v2/login_information' --header 'Content-Type:application/json' --header 'Accept:application/json' --header 'X-DocuSign-Authentication:{"<redacted>", "Password": "<redacted>", "IntegratorKey": "<redacted>"}'
{
  "loginAccounts": [
    {
      "name": "<redacted>",
      "accountId": "<redacted>",
      "baseUrl": "https://demo.docusign.net/restapi/v2/accounts/<redacted>",
      "isDefault": "true",
      "userName": "<redacted>",
      "userId": "<redacted>",
      "email": "<redacted>",
      "siteDescription": ""
    }
  ]

However, when trying to authenticate using an HTTP request through PHP, I receive a '401 Unauthorized' response, with the body:

'{
  "errorCode": "PARTNER_AUTHENTICATION_FAILED",
  "message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
}'

I'm pretty sure I'm setting an IntegratorKey header. My PHP code looks like:

$request = new \http\Client\Request('GET', $url, $this->getHeaders());
$client = new \http\Client();
$client->enqueue($request)->send();
$response = $client->getResponse();

I'm using the pecl/http-v2 HTTP library (docs at: http://devel-m6w6.rhcloud.com/mdref/http )

$url evals to: 'https://demo.docusign.net/restapi/v2/login_information'

The header array looks like:

array (size=3)
    0 => string 'X-DocuSign-Authentication: {"Username": "<redacted>", "Password":  "<redacted>", "IntegratorKey": "<redacted>"}' (length=155)
    1 => string 'Content-Type: application/json' (length=30)
    2 => string 'Accept: application/json' (length=24)

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!

Edit: 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.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题