Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 合作伙伴\u身份验证\u失败:未找到或禁用指定的集成器密钥。未指定积分器密钥_Python_Django_Docusignapi - Fatal编程技术网

Python 合作伙伴\u身份验证\u失败:未找到或禁用指定的集成器密钥。未指定积分器密钥

Python 合作伙伴\u身份验证\u失败:未找到或禁用指定的集成器密钥。未指定积分器密钥,python,django,docusignapi,Python,Django,Docusignapi,我正在开发一个Django Web应用程序,用于通过电子邮件向用户发送文档,并使用Docusign API实现此目的。我正在使用JWT Grant身份验证,并且已经成功地获得了工作正常的访问令牌 现在,我想通过电子邮件向用户发送一份文档以供签署。为此,我使用以下代码: from django.shortcuts import render from django.http import JsonResponse from docusign_esign import EnvelopeDefinit

我正在开发一个Django Web应用程序,用于通过电子邮件向用户发送文档,并使用Docusign API实现此目的。我正在使用JWT Grant身份验证,并且已经成功地获得了工作正常的访问令牌

现在,我想通过电子邮件向用户发送一份文档以供签署。为此,我使用以下代码:

from django.shortcuts import render
from django.http import JsonResponse
from docusign_esign import EnvelopeDefinition, Recipients, Tabs, SignHere, Signer, CarbonCopy, Document, EnvelopesApi, ApiClient
import base64


ACCESS_TOKEN = 'MY_ACCESS_TOKEN'
ACCOUNT_ID = 'MY_ACCOUNT_ID'
BASE_PATH = 'demo.docusign.net/restapi'


def create_document(signer_name, signer_email, cc_name, cc_email):
    return f"""
        <!DOCTYPE html>
        <html>
            <head>
              <meta charset="UTF-8">
            </head>
            <body style="font-family:sans-serif;margin-left:2em;">
            <h1 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
                color: darkblue;margin-bottom: 0;">World Wide Corp</h1>
            <h2 style="font-family: "Trebuchet MS", Helvetica, sans-serif;
              margin-top: 0px;margin-bottom: 3.5em;font-size: 1em;
              color: darkblue;">Order Processing Division</h2>
            <h4>Ordered by {signer_name}</h4>
            <p style="margin-top:0em; margin-bottom:0em;">Email: {signer_email}</p>
            <p style="margin-top:0em; margin-bottom:0em;">Copy to: {cc_name}, {cc_email}</p>
            <p style="margin-top:3em;">
                Candy bonbon pastry jujubes lollipop wafer biscuit biscuit. Topping brownie sesame snaps sweet roll pie.
                Croissant danish biscuit soufflé caramels jujubes jelly. Dragée danish caramels lemon drops dragée.
                Gummi bears cupcake biscuit tiramisu sugar plum pastry. Dragée gummies applicake pudding liquorice.
                Donut jujubes oat cake jelly-o.
                Dessert bear claw chocolate cake gummies lollipop sugar plum ice cream gummies cheesecake.
            </p>
            <!-- Note the anchor tag for the signature field is in white. -->
            <h3 style="margin-top:3em;">Agreed: <span style="color:white;">**signature_1**/</span></h3>
            </body>
        </html>
      """


def make_envelope():
    env = EnvelopeDefinition(email_subject='Please sign this document set')
    doc = base64.b64encode(bytes(create_document('user@example.com', 'M Aaqib',
                                                 'user1@example.com', 'Aaqib'), "utf-8")).decode("ascii")
    document = Document(document_base64=doc, name="Order acknowledgement", file_extension="html", document_id="1")
    env.documents = [document]
    signer = Signer(email='user@example.com', name='M Aaqib', recipient_id="1", routing_order="1")
    cc = CarbonCopy(email='user1@example.com', name='Aaqib', recipient_id="2", routing_order="2")
    sign_here = SignHere(anchor_string="**signature_1**", anchor_units="pixels",
                         anchor_y_offset="10", anchor_x_offset="20")
    signer.tabs = Tabs(sign_here_tabs=[sign_here])
    recipients = Recipients(signers=[signer], carbon_copies=[cc])
    env.status = 'sent'
    return env


def worker():
    envelope_definition = make_envelope()
    api_client = ApiClient()
    api_client.host = BASE_PATH
    api_client.set_default_header("Authorization", f"Bearer {ACCESS_TOKEN}")
    envelopes_api = EnvelopesApi(api_client)
    results = envelopes_api.create_envelope(ACCOUNT_ID, envelope_definition=envelope_definition)
    envelope_id = results.envelope_id
    return {"envelope_id": envelope_id}


def home(request):
    return JsonResponse(worker())


如果有人能在这方面指导我,我将非常感激。所以,基本上我犯了一个非常愚蠢的错误。我在基本路径中缺少
https://

它应该是:
BASE\u PATH=https://demo.docusign.net/restapi“


因此,基本上我犯了一个非常愚蠢的错误。我在基本路径中缺少
https://

它应该是:
BASE\u PATH=https://demo.docusign.net/restapi“

而不是:
BASE\u PATH='demo.docusign.net/restapi'

ApiException at /
(401)
Reason: Unauthorized
HTTP response headers: HTTPHeaderDict({'Cache-Control': 'no-cache', 'Content-Length': '153', 'Content-Type': 'application/json; charset=utf-8', 'X-DocuSign-TraceToken': '285033cb-cc24-4d43-a6e8-1231a89843c2', 'X-DocuSign-Node': 'DA4DFE71', 'Date': 'Sun, 20 Dec 2020 01:13:09 GMT', 'Vary': 'Accept-Encoding'})
HTTP response body: b'{"errorCode":"PARTNER_AUTHENTICATION_FAILED","message":"The specified Integrator Key was not found or is disabled. An Integrator key was not specified."}'