Docusign:带有访问代码问题的嵌入式签名 - 无法使用收件人查看 URL 进行签名

问题描述 投票:0回答:1

我正在创建一个使用 Docusign API 的 Python 应用程序。我创建了一个信封并需要访问代码。但我想使用嵌入式签名,因此我进行了另一个 API 调用来获取收件人视图。但对于返回的 URL,我无法签名,也不会询问访问代码。如果我通过收到的电子邮件签名,系统会要求我提供访问代码,一切正常

#Construct the Base URL
base_uri = f"{base_url}/accounts/{account_id}"

#Create the Envelope Definition
envelope_definition = {
    "emailSubject": "Please Sign the Document",  # Add a subject line
    "documents": [{"documentBase64": "", "name": "Document.pdf", "fileExtension": "pdf", "documentId": "1"}],
    "recipients": {
        "signers": [
            {
                "email": recipient_email,
                "name": recipient_name,
                "recipientId": "1",
                "tabs": {
                    "signHereTabs": [{"anchorString": "/sn1/", "anchorUnits": "pixels", "anchorXOffset": "10", "anchorYOffset": "10"}]
                },
                "templateAccessCodeRequired": None,
                "deliveryMethod": "email",
                "smsAuthentication": None,
        "idCheckConfigurationName": None,
                "requireIdLookup": False,
                "accessCode": "123456",

            }
        ]
    },
    "status": "sent",
}

with open(pdf_path, "rb") as file:
    content_bytes = file.read()
    content_base64 = base64.b64encode(content_bytes).decode('utf-8')
    envelope_definition["documents"][0]["documentBase64"] = content_base64

#Send the Envelope
url = f"{base_uri}/envelopes"
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
}
response = requests.post(url, headers=headers, json=envelope_definition)

# Check for errors in the response
if response.status_code != 201:
    print(f"Error creating envelope. Status code: {response.status_code}")
    print(response.text)
    exit()

envelope_id = response.json()["envelopeId"]
print(response.json()["uri"])

#Get the Signing URL
url = f"{base_uri}/envelopes/{envelope_id}/views/recipient"
recipient_view_request = {
    "returnUrl": "https://www.example.com/success",
    "authenticationMethod": "none",
    "email": recipient_email,
    "userName": recipient_name,
}
response = requests.post(url, headers=headers, json=recipient_view_request)
print(response.json())
signing_url = response.json()["url"]


#Return the Signing URL
print(f"Signing URL: {signing_url}")

这是我的代码。我查看了 DocuSign 网站,但没有发现任何与authenticationMethod匹配的内容

我能够通过收件人视图的 URL 签署文档,无需访问代码

docusignapi
1个回答
0
投票

您的代码中有两个地方缺少 clientUserId。这是更新的代码:

#Construct the Base URL
base_uri = f"{base_url}/accounts/{account_id}"

#Create the Envelope Definition
envelope_definition = {
    "emailSubject": "Please Sign the Document",  # Add a subject line
    "documents": [{"documentBase64": "", "name": "Document.pdf", "fileExtension": "pdf", "documentId": "1"}],
    "recipients": {
        "signers": [
            {
                "email": recipient_email,
                "name": recipient_name,
                "recipientId": "1",
                "tabs": {
                    "signHereTabs": [{"anchorString": "/sn1/", "anchorUnits": "pixels", "anchorXOffset": "10", "anchorYOffset": "10"}]
                },
                "templateAccessCodeRequired": None,
                "deliveryMethod": "email",
                "smsAuthentication": None,
        "idCheckConfigurationName": None,
                "requireIdLookup": False,
                "accessCode": "123456",
                "clientUserId" : "1001",
            }
        ]
    },
    "status": "sent",
}

with open(pdf_path, "rb") as file:
    content_bytes = file.read()
    content_base64 = base64.b64encode(content_bytes).decode('utf-8')
    envelope_definition["documents"][0]["documentBase64"] = content_base64

#Send the Envelope
url = f"{base_uri}/envelopes"
headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json",
}
response = requests.post(url, headers=headers, json=envelope_definition)

# Check for errors in the response
if response.status_code != 201:
    print(f"Error creating envelope. Status code: {response.status_code}")
    print(response.text)
    exit()

envelope_id = response.json()["envelopeId"]
print(response.json()["uri"])

#Get the Signing URL
url = f"{base_uri}/envelopes/{envelope_id}/views/recipient"
recipient_view_request = {
    "returnUrl": "https://www.example.com/success",
    "authenticationMethod": "none",
    "email": recipient_email,
    "clientUserId" : "1001",
    "userName": recipient_name,
}
response = requests.post(url, headers=headers, json=recipient_view_request)
print(response.json())
signing_url = response.json()["url"]


#Return the Signing URL
print(f"Signing URL: {signing_url}")
© www.soinside.com 2019 - 2024. All rights reserved.