我的目标:获取令牌以发送数字签名请求(服务器到服务器)环境:PHP、Symfony - 演示环境这是我在运行以下代码时收到的错误:错误:“consent_required”我的代码:class ServiceSignature{ private $container; private $accessToken; private $accountId; private $signerName; private $signerEmail; private $fileNamePath; private $basePath; private $appPath; public function __construct(ContainerInterface $container) { $this->container = $container; $this->accountId = "dc295354-xxxx-xxxx-xxxx-f2e3a8813b1e"; $this->basePath = 'https://demo.docusign.net/restapi'; $this->appPath = $_ENV["FOLDER_UPDATE"]; $this->accessToken = ""; $this->private_key_path = "../docusign_private.pem"; $this->private_key = file_get_contents($this->private_key_path); $this->cle_integration = "bdfeaf70-xxxx-xxxx-xxxx-8a2ed57eb7ef"; $this->audience = "account-d.docusign.com"; $this->permission_scopes= "signature impersonation"; $this->token = $this->getToken(); } public function getToken() { $current_time = time (); $_token = [ "iss" => $this->cle_integration, "sub" => $this->accountId, "aud" => $this->audience, "scope" => $this->permission_scopes, "nbf" => $current_time, "exp" => $current_time + 60*1000 ]; $jwt = JWT::encode($_token, $this->private_key, 'RS256'); $headers = ['Accept' => 'application/json']; $data = ['grant_type' => 'urn:ietf:params:oauth:grant-type:jwt-bearer', 'assertion' => $jwt]; $body = Unirest\Request\Body::form($data); $response = Unirest\Request::post("https://{$this->audience}/oauth/token", $headers, $body); if (strpos($response->raw_body, '<html>') !== false) { throw new Exception("An error response was received!\n\n"); } $json = $response->body; dump($json); die(); }}先感谢您
1 回答
LEATH
TA贡献1936条经验 获得超6个赞
问题很可能是您提供的用户 GUID 尚未同意。
按照本指南获得同意,您应该一切顺利。
摘录:
当应用程序进行身份验证以代表用户执行操作时,将要求该用户对应用程序请求的范围集(权限集)授予同意,除非他们之前已经授予该同意。
要开始身份验证并获得同意,您的应用程序会将用户的浏览器重定向到 DocuSign 授权 URI。请注意,这不是标准的 GET 请求,不能由应用程序直接发送。相反,用户的浏览器被重定向到授权请求 URI,请求从那里发送到帐户服务器。
- 1 回答
- 0 关注
- 180 浏览
添加回答
举报
0/150
提交
取消