Salesforce的DocuSign隐式赠款

问题描述

我正在使用Rest API将DocuSign与salesforce集成以便发送信封。 在发送任何信封之前,我一直在进行隐式授予以生成令牌,但是我不确定哪种方法是正确的。 我正在使用GET方法,但正在获取HTML格式的响应。

run_the_exec

我得到以下输出

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());
}
}

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

解决方法

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

请参阅工具包的authentication instructions

如果您不使用APEX工具包,则需要在SalesForce的功能范围内工作。 Named Credentials是一种方法。 Here's另一个。