我正在使用 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