codeigniter 尝试连接API以使用docusign时显示PARTNER_AUTHENTICATION_FAILED [已关闭]

axkjgtzd  于 8个月前  发布在  其他
关注(0)|答案(1)|浏览(49)

已关闭,此问题需要details or clarity。它目前不接受回答。
**想改善这个问题吗?**通过editing this post添加详细信息并澄清问题。

3天前关闭。
Improve this question

**Fatal error**: Uncaught DocuSign\\eSign\\Client\\ApiException:
 Error while requesting server, received a non successful HTTP code \[401\] with response Body: O:8:"stdClass":2:
{s:9:"errorCode";s:29:"PARTNER_AUTHENTICATION_FAILED";s:7:
"message";s:95:"The specified Integrator Key was not found or is disabled. 
An Integrator key was not specified.";} 
in C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\system\\vendor\\docusign\\esign-client\\src\\Client\\ApiClient.php:344 Stack trace: #0 
C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\system\\vendor\\docusign\\esign-client\\src\\Api\\EnvelopesApi.php(4606): DocuSign\\eSign\\Client\\ApiClient-\>callApi('/v2.1/accounts/...', 'POST', Array, '{"documents":\[{...', Array, '\\\\DocuSign\\\\eSign...', '/v2.1/accounts/...') #1 
C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\system\\vendor\\docusign\\esign-client\\src\\Api\\EnvelopesApi.php(4525): DocuSign\\eSign\\Api\\EnvelopesApi-\>createEnvelopeWithHttpInfo('f2494a1d-3507-4...', Object(DocuSign\\eSign\\Model\\EnvelopeDefinition), NULL) #2 
C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\application\\controllers\\docusign.php(68): DocuSign\\eSign\\Api\\EnvelopesApi-\>createEnvelope('f2494a1d-3507-4...', Object(DocuSign\\eSign\\Model\\EnvelopeDefinition)) #3 
C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\system\\core\\CodeIgniter.php(360): docusign-\>signdocument('2133') #4 
C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\index.php(202): require_once('C:\\\\xampp\\\\htdocs...') #5 {main} thrown in **C:\\xampp\\htdocs\\affiniks_staging\\affiniks\\app\\system\\vendor\\docusign\\esign-client\\src\\Client\\ApiClient.php** on line **344**
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

require_once (BASEPATH . 'vendor/autoload.php');

use DocuSign\eSign\Api\EnvelopesApi;
use DocuSign\eSign\ApiClient;
use DocuSign\eSign\Configuration;
use DocuSign\eSign\Model\Signer;
use DocuSign\eSign\Model\EnvelopeDefinition;
use DocuSign\eSign\Model\Document;

class docusign extends CI_Controller {

    public function __construct() {
        parent::__construct();
        // Load the DocuSign configuration and set the API credentials
        $config = new Configuration();
        $accessToken ='***********';
        $config->addDefaultHeader("X-DocuSign-Authentication", 
        json_encode([
        "Username" => "*****", // Replace with your DocuSign email
        "Password" => "*****", // Replace with your DocuSign password
        "IntegratorKey" => "******" // Replace with your Integrator Key
        ])
        );

        $config->setHost('https://demo.docusign.net/restapi');
        $config->addDefaultHeader("Authorization", "Bearer " . $accessToken);

      
       $apiClient = new DocuSign\eSign\Client\ApiClient($config);

        // $config->setClientId('****'); // Your DocuSign client ID
        // $config->setClientSecret('******'); // Your DocuSign client secret

        
    }

    public function signdocument($userId) {
        // Load the document that corresponds to the user
        $documentPath = 'affiniks_doc.docx';

        // Create an envelope definition
        $envelopeDefinition = new EnvelopeDefinition([
            'status' => 'sent',
            'documents' => [new Document([
                'document_base64' => base64_encode(file_get_contents($documentPath)),
                'name' => 'affiniks_doc.docx',
                'file_extension' => 'docx',
                'document_id' => '1',
            ])],
            'recipients' => [new Signer([
                'email' => '******', // User's email address
                'name' => '****',
                'recipient_id' => '1',
                'client_user_id' => $userId, // Unique identifier for the user
                'tabs' => [],
            ])],
        ]);

        $config = new Configuration();

        $apiClient = new DocuSign\eSign\Client\ApiClient($config);
        // Create the envelope and get the signing URL
        $envelopesApi = new EnvelopesApi($apiClient);
        $envelopeSummary = $envelopesApi->createEnvelope('*********', $envelopeDefinition);

        // Redirect the user to the DocuSign signing URL
        $redirectUrl = $envelopeSummary->getEnvelopeId();
        redirect($redirectUrl); // You may need to customize this redirection
    }
}
oogrdqng

oogrdqng1#

看起来您正在尝试使用基本身份验证,但现在已弃用。您需要修改集成以使用OAuth2.0并使用访问令牌进行身份验证。
阅读公告here了解更多信息。

相关问题