简体   繁体   中英

Docusign authentication fails from one server, same code works on several others. (PHP Docusign SDK)

I have some code I've been working on that is just a wrapper class around the Docusign PHP SDK, in order to tailor it to our application a little more. The problem is that now, authentication has started failing from our production server, but the exact same code (literally a verbatim copy) works fine on other servers. I am at a loss for what is going on with this.

Here's the failure:

Exception: exception 'DocuSign\eSign\ApiException' with message 'API call to https://demo.docusign.net/restapi/v2/login_information timed out: a:26:{s:3:"url";s:54:"https://demo.docusign.net/restapi/v2/login_information";s:12:"content_type";N;s:9:"http_code";i:0;s:11:"header_size";i:0;s:12:"request_size";i:0;s:8:"filetime";i:-1;s:17:"ssl_verify_result";i:1;s:14:"redirect_count";i:0;s:10:"total_time";d:0.168601;s:15:"namelookup_time";d:0.004248;s:12:"connect_time";d:0.081040000000000001;s:16:"pretransfer_time";d:0;s:11:"size_upload";d:0;s:13:"size_download";d:0;s:14:"speed_download";d:0;s:12:"speed_upload";d:0;s:23:"download_content_length";d:-1;s:21:"upload_content_length";d:-1;s:18:"starttransfer_time";d:0;s:13:"redirect_time";d:0;s:12:"redirect_url";s:0:"";s:10:"primary_ip";s:14:"162.248.184.25";s:8:"certinfo";a:0:{}s:12:"primary_port";i:443;s:8:"local_ip";s:14:"10.231.215.217";s:10:"local_port";i:39287;}' in /srv/www/vhosts/redacted.com/pages/test/docusign/sdk/docusign-php-client-master/src/ApiClient.php:233
Stack trace:
#0 /srv/www/vhosts/redacted.com/pages/test/docusign/sdk/docusign-php-client-master/src/Api/AuthenticationApi.php(264): DocuSign\eSign\ApiClient->callApi('/v2/login_infor...', 'GET', Array, '', Array, '\DocuSign\eSign...')
#1 /srv/www/vhosts/redacted.com/pages/test/docusign/sdk/docusign-php-client-master/src/Api/AuthenticationApi.php(193): DocuSign\eSign\Api\AuthenticationApi->loginWithHttpInfo(Object(DocuSign\eSign\Api\AuthenticationApi\LoginOptions))
#2 /srv/www/vhosts/redacted.com/pages/test/docusign/myclass.php(46): DocuSign\eSign\Api\AuthenticationApi->login(Object(DocuSign\eSign\Api\AuthenticationApi\LoginOptions))
#3 /srv/www/vhosts/redacted.com/pages/test/docusign/myclass.php(41): DocuSignWrapper->doLogin()
#4 /srv/www/vhosts/redacted.com/pages/test/docusign/classtest.php(130): DocuSignWrapper->__construct()
#5 

And successful send from any of four other servers I've put the code on:

{
    "envelopeId": "881f8fb2-d089-49e5-b70c-8fab37ddc717",
    "uri": "\/envelopes\/881f8fb2-d089-49e5-b70c-8fab37ddc717",
    "statusDateTime": "2016-12-19T16:47:34.3265610Z",
    "status": "sent"
}

Here is the relevant part of the wrapper class (constructor and login function, with auth info redacted):

function __construct()
{
    $this->config = new DocuSign\eSign\Configuration();
    $this->config->setHost($this->host);
    $this->config->addDefaultHeader("X-DocuSign-Authentication", '{"Username":"' . $this->username . '",
                                    "Password":"' . $this->password . '",
                                    "IntegratorKey":"' . $this->integratorKey . '"}');
    $this->apiClient = new DocuSign\eSign\ApiClient($this->config);
    $this->authApi = new DocuSign\eSign\Api\AuthenticationApi($this->apiClient);
    $this->options = new DocuSign\eSign\Api\AuthenticationApi\LoginOptions();
    $this->doLogin();
}

function doLogin()
{
    $loginInfo = $this->authApi->login($this->options);
    if (isset($loginInfo) && count($loginInfo) > 0)
    {
        $loginAccount = $loginInfo->getLoginAccounts()[0];
        if (isset($loginInfo))
        {
            $this->accountId = $loginAccount->getAccountId();
        }
    }
}

I really could use some help trying to figure out how and why this is happening, as my project is stalled from moving into production by this. I should note that authentication still did work up till approximately a week ago and the code did not change. It has to be something else.

Thanks for any help!

A couple of ideas:

  1. You're constructing the authentication header manually instead of using the PHP JSON conversion method. The difference is that you're not escaping any characters in the username or password that need to be escaped.

    So make sure that you're testing with the name credentials. (Plus this is a lurking bug that you should fix.)

  2. Obviously something different is happening between your two servers. The best is to observe what is being sent and compare the two.

    If your request is making it through enough of the DocuSign stack to be logged, then compare the DocuSign logs. Article .

    If not, then either log/peek at the output of your machine using an appropriate debugging tool. Or you can send your request to a requestb.in endpoint and compare the two servers' requests that way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM