docusignapi - 无法登录 Docusign

标签 docusignapi

$(document).ready(function () {
debugger;
$.ajax({
        type: "GET",
        headers: {
        "Accept" : "application/json",
        "Content-Type": "application/json"
        },
        beforeSend: function (request) {
        // request.setRequestHeader("X-DocuSign-Authentication"
        // , "<DocuSignCredentials><Username>*******</Username><Password>****** </Password>    <IntegratorKey>******</IntegratorKey></DocuSignCredentials>");
        request.setRequestHeader("X-DocuSign-Authentication"
        ,"{\"Username\":\"********\",\"Password\":\"*****\",\"IntegratorKey\":\"*******\"}");
        },
        url: "https://demo.docusign.net/restapi/v2/login_information?    api_password=false&include_account_id_guid=tr...
        success: function (r) {
            debugger;
        },
        error: function (xhr) {
          alert(xhr.responseText);
        }
    });
});

我用上面的方法登录,我得到的响应代码是 200。但是响应总是空白。即使我输入了错误的密码,它仍然会给出 200。 此外,在 API 部分 Activate In 部分是空白的。请提出解决方案

最佳答案

错误 No 'Access-Control-Allow-Origin' header is present on the requested resource 表示无法通过 jQuery/AJAX 访问 DocuSign。您将要通过另一种语言执行登录请求并将变量传递给 JS

这里是我在上面用 PHP 提供的答案的更多详细信息。

这是一个简单的例子,我只是拼凑在一起来展示应该完成的过程,必须对其进行修改以满足您的需求(特别是如果您不使用 PHP)。

HTML 页面:

<div id='divBox'>Logging into DocuSign...</div>
<script src="js/jQuery2.1.1.js"></script>
<script>
$(function (){
  $.ajax({
    type: "GET",
    url: "script.php",
    dataType: "json",
    success: function( data ){
      if(!data.errorCode)
      {
        $('#divBox').html('Logged Into ' + data.name + ' (' + data.accountId + ') account!');
      }else{
        $('#divBox').html('Failed to Login!<br>Error: ' + data.errorCode);
      }
    },
    error: function(){
      alert("error");
    }
  });
});
</script>

脚本.php:

<?
$email = "ENTER EMAIL HERE";
$password = "ENTER PASSWORD HERE";
$integratorKey = "ENTER INTEGRATOR KEY HERE";

$url = "https://demo.docusign.net/restapi/v2/login_information?include_account_id_guid=true";
$header = "<DocuSignCredentials><Username>" . $email . "</Username><Password>" . $password . "</Password><IntegratorKey>" . $integratorKey . "</IntegratorKey></DocuSignCredentials>";

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array("X-DocuSign-Authentication: $header"));
$json_response = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);

if($status==200){
  $response = json_decode($json_response, true);
  print_r(json_encode($response['loginAccounts'][0]));
}else{
  print_r($json_response);
}

关于docusignapi - 无法登录 Docusign,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25518778/

相关文章:

javascript - 使用 SuiteScript 2.x 为 DocuSign API 集成创建 JWT

docusignapi - 如何向模板角色添加短信验证?

javascript - 从 Node.JS 向 DocuSign 发送请求时强制设置 TLS 版本 1.2

java - 使用 Java 列出信封状态更改 PARTNER_AUTHENTICATION_FAILED

docusignapi - "errorCode": "USER_DOES_NOT_BELONG_TO_SPECIFIED_ACCOUNT"

docusignapi - 未找到或禁用 DocuSign 集成器 key

c# - Docusign ID Check 功能无法通过 API 运行

apache - 使用 Docusign API curl SSL 相关连接超时

php - 运行 DocuSign 示例 PHP 代码?

docusignapi - 使用 DocuSign API 将两个模板合二为一