Hello i've tried to implement docusign in my project and i have followed this exemple : https://www.docusign.com/blog/developers/send-document-laravel-jwt-grant-authentication but i can' make it works, when i try to authenticate I've got this error "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";}" i already granted the consent in docusign here is the image that's shows the consent in docusign.
if someone can help me i will be grateful or if you could provide me guidance through docusign using jwt without showing login form that will help me a lot.
i've also tried to follow this https://developers.docusign.com/docs/esign-rest-api/sdks/php/auth/ but i can't figured it out.
thanks a lot.
Update
here is my controller i call the function send on Submit : 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;
}