Laravel集成DocuSign JWT认证遇consent_required错误求助
Laravel集成DocuSign JWT认证时出现
consent_required错误 我在Laravel项目中集成DocuSign,按照教程操作后无法正常运行,认证阶段抛出以下错误:
Error while requesting server, received a non successful HTTP code [400] with response Body: O:8:"stdClass":1:{s:5:"error";s:16:"consent_required";}
我已经在DocuSign后台完成了授权操作,授权状态截图。
恳请大家帮忙解决这个问题,或者指导我如何在不显示登录表单的情况下使用JWT集成DocuSign。我也尝试过官方文档,但问题仍未解决。
感谢帮助。
更新
以下是控制器代码,提交时会调用send方法:
public function send(Request $request): object{ /** * * Step 1 * Instantiate the eSign API client and set the OAuth path used by the JWT request * * Generate a new JWT access token * */ $apiClient = new ApiClient(); $apiClient->getOAuth()->setOAuthBasePath(config('app.auth_server')); try{ $accessToken = $this->getToken($apiClient); } catch (\Throwable $th) { return back()->withError($th->getMessage())->withInput(); } /** * * Step 2 * Get user's info i.e. accounts array and base path * * Update the base path. The result in demo will be https://demo.docusign.net/restapi * User default account is always first in the array * */ $userInfo = $apiClient->getUserInfo($accessToken); $accountInfo = $userInfo[0]->getAccounts(); $apiClient->getConfig()->setHost($accountInfo[0]->getBaseUri() . config('app.sufix')); /** * * Step 3 * Build the envelope object * * Make an API call to create the envelope and display the response in the view * */ $envelopeDefenition = $this->buildEnvelope($request); try { $envelopeApi = new EnvelopesApi($apiClient); $result = $envelopeApi->createEnvelope($accountInfo[0]->getAccountId(), $envelopeDefenition); } catch (\Throwable $th) { return back()->withError($th->getMessage())->withInput(); } return view('contract.response')->with('result', $result); } private function getToken(ApiClient $apiClient) : string{ try { $privateKey = file_get_contents(storage_path(config('app.keypath')),true); $response = $apiClient->requestJWTUserToken( $ikey = config('app.client'), $userId = config('app.user_id'), $key = $privateKey, $scope = config('app.JWT_SCOPE') ); $token = $response[0]; dd($token); $accessToken = $token->getAccessToken(); } catch (\Throwable $th) { throw $th; } return $accessToken; }
内容的提问来源于stack exchange,提问作者Rubyjane
相关产品推荐
相关产品推荐

