在文档中调用 docusign 时,总是收到 AUTHORIZATION_INVALID_TOKEN 错误消息

问题描述 投票:0回答:1

此处帐户详细信息:

$integrationKey = '9eaed807-bd9f-4d38-b858-37f6eccc6b73'; // Your Integration Key
$userId = 'd4300ed6-aa42-47cd-b687-01c825726abd'; // Your User ID (GUID)
$accountId = '8c637b59-afa2-4821-8c5d-981bacf4ddde'; // Your Account ID

尝试使用 PHP 签名时,总是出现此错误:

发送信封时出错:

请求服务器时出错,收到不成功的 HTTP 代码 [401] 响应正文: O:8:"stdClass":2:{s:9:"errorCode";s:27:"AUTHORIZATION_INVALID_TOKEN";s:7:"消息";s:59:" 提供的访问令牌已过期、撤销或格式错误。";}

请检查并提出解决方案。

想要得到成功回复。

docusignapi
1个回答
0
投票

您没有提供实际的代码,但这里是适用于您需要执行的操作的 PHP 代码:

(代码位于 https://github.com/docusign/code-examples-php/blob/master/src/Services/JWTService.php

 self::$apiClient->getOAuth()->setOAuthBasePath($GLOBALS['JWT_CONFIG']['authorization_server']);
        $privateKey = file_get_contents(
            $_SERVER['DOCUMENT_ROOT'] . '/' . $GLOBALS['JWT_CONFIG']['private_key_file'],
            true
        );

        $scope = (new DocuSign())->getDefaultScopes()[0];
        $jwt_scope = $scope;

        try {
            $response = self::$apiClient->requestJWTUserToken(
                $aud = $GLOBALS['JWT_CONFIG']['ds_client_id'],
                $aud = $GLOBALS['JWT_CONFIG']['ds_impersonated_user_id'],
                $aud = $privateKey,
                $aud = $jwt_scope
            );

            return $response[0]; 

$envelope_definition = EmbeddedSigningService::makeEnvelope($args["envelope_args"], $demoPath, $pdfFile);
        $envelope_api = $clientService->getEnvelopeApi();

        # Call Envelopes::create API method
        # Exceptions will be caught by the calling function
        try {
            $envelopeSummary = $envelope_api->createEnvelope($args['account_id'], $envelope_definition);
        } catch (ApiException $e) {
            $clientService->showErrorTemplate($e);
            exit;
        }
        $envelope_id = $envelopeSummary->getEnvelopeId();
© www.soinside.com 2019 - 2024. All rights reserved.