0

我正在使用 Rest API 将 DocuSign 与 salesforce 集成以发送信封。在发送任何信封之前,我正在处理隐式授权以生成令牌,但我不确定获取令牌的正确方法是什么。我正在使用 GET 方法,但我得到的是 HTML 格式的响应。

public class SendDocumentsWithDocuSign {  
    
    public void test(){
        String accountID = 'a6e74d5a-****-****-****-28f3bec67ccf'; 
        String userName = 'f2326e06-****-****-****-a1aee682da08'; 
        String passWord = 'password@123'; 
        String integrationKey = 'b19b477c-****-****-a8a5-8ff88ea771cc';
        String templateID = '5259faf7-****-****-a493-ba19ce5d633c'; 
        String redirectURL='https://www.salesforce.com';
        
        //Request the implicit grant
        String TOKEN_URL = 'https://account-d.docusign.com/oauth/auth?response_type=token&scope=signature&client_id='+integrationKey+'&redirect_uri='+redirectURL;
        String authenticationHeader = 
            '<DocuSignCredentials>' + 
            '<Username>' + userName+ '</Username>' +
            '<Password>' + password + '</Password>' + 
            '<IntegratorKey>' + integrationKey  + '</IntegratorKey>' + 
            '</DocuSignCredentials>';           
        
        
        HttpRequest httpreq = new HttpRequest();
        HttpResponse httpres = new HttpResponse();
        Http httpCall = new Http();        
        
        httpreq.setEndpoint(TOKEN_URL);
        httpreq.setMethod('GET');
        //httpreq.setHeader('X-DocuSign-Authentication', authenticationHeader);
        httpreq.setHeader('Content-Type', 'application/json');
        httpreq.setHeader('Accept', 'application/json');
        httpres = httpCall.send(httpreq);
        System.debug(httpres.getHeaderKeys());
        System.debug(httpres.getHeader('X-DocuSign-TraceToken'));
        System.debug(httpres.getHeader('Set-Cookie'));
        System.debug(httpres.getBody());
}
}

我得到以下输出。

[32]|DEBUG|(X-DocuSign-Node, X-Content-Type-Options, X-DocuSign-TraceToken, Pragma, Date, X-Frame-Options, Strict-Transport-Security, Cache-Control, Content-Security-Policy, Set-Cookie, ...)
[33]|DEBUG|4d4cac98-7cc9-4b3e-a1fe-c12e871b7065
[34]|DEBUG|__RequestVerificationToken=ARFea2sGN3iGpAjBGHGwCJcB0; path=/; secure; HttpOnly
[35]|DEBUG|

 input name="__RequestVerificationToken" type="hidden" value="ARFea2sGN3iGpAjBGHGwCJcAAAAA0"

我想获取访问令牌以调用 DocuSign 文档中给出的 REST API。https://developers.docusign.com/platform/auth/implicit/implicit-get-token

4

1 回答 1

0

要使用 DocuSign APEX 工具包,您需要遵循工具包的身份验证方法,因为这是使用 APEX 工具包中的(所需)集成密钥的唯一方法。

请参阅工具包的身份验证说明

如果您不使用 APEX 工具包,那么您需要在 SalesForce 的能力范围内工作。命名凭据是一种方法。这是另一个。

于 2020-10-25T12:02:28.847 回答