Radek S
Radek S

Reputation: 117

PARTNER_AUTHENTICATION_FAILED after succesfull geting access token using JWT

  1. I am trying to establish connection between my Application and DocuSign Sandbox.

  2. I'am using JWT Authorization.

  3. I have Integration key with RSA private key generated.
  4. I have user to impersonate with GUID and consent aquired
  5. I call https://account-d.docusign.com/oauth/token with proper data which response with success and give me back Access token

Everything works well until this moment.

I've downloaded library for PHP "docusign/esign-client"

and used this fragment of code:

        $recipientId = uniqid(5);
        $clientUserId =  uniqid(5);

        $document = new Document([
            'document_base64' => $base64FileContent,
            'name' => 'Application Form',
            'file_extension' => 'pdf',
            'document_id' => '1'
        ]);

        $signer = new Signer([
            'email' => $email,
            'name' => $name,
            'recipient_id' => $recipientId,
            'routing_order' => "1",
            'client_user_id' => $clientUserId,
        ]);

        $signHere = new SignHere([
            'document_id' => '1', 'page_number' => '3', 'recipient_id' => $recipientId,
            'tab_label' => 'SignHereTab', 'x_position' => '195', 'y_position' => '147'
        ]);

        $signer->setTabs(new Tabs(['sign_here_tabs' => [$signHere]]));

        $envelopeDefinition = new EnvelopeDefinition([
            'email_subject' => "Please sign this document",
            'documents' => [$document],
            'recipients' => new Recipients(['signers' => [$signer]]),
            'status' => "sent"
        ]);

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

        $apiClient = new ApiClient($config);
        $envelopeApi = new EnvelopesApi($apiClient);

        $results = $envelopeApi->createEnvelope($integrationKey, $envelopeDefinition);  

The result is an error (400) comes from API with info:

PARTNER_AUTHENTICATION_FAILED
The specified Integrator Key was not found or is disabled. Invalid account specified for user.

It says integration key is wrong but few lines before I used this integration key to generate Access Token with success.

Do you have any idea whats is going wrong ?

Before JWT integrations, I was using different integration key and access token from OAuth Token Generator and it worked fine (this previous key didn't have RSA generated)

Could you guys help me with that issue ?

If any more informations could help to find a solution just let me know and I will update my post.

Thanks for help.

Upvotes: 0

Views: 501

Answers (1)

Drew
Drew

Reputation: 5029

The issue is in this line

 $results = $envelopeApi->createEnvelope($integrationKey, $envelopeDefinition);

The first parameter of the createEnvelope method should be the Account ID, not the integrator key.

After you receive the access token, you can make a UserInfo call and pull the account ID from that.

Upvotes: 2

Related Questions