The Problem: DocuSign seems to ignore the redirect_uri that's set in the HTTP header when obtaining an access token.
For context, I am using PHP and cURL. When I send the cURL request, the authorization succeeds because I do get the access token and refresh tokens. The only issue is that DocuSign does not perform a redirect after the authorization's success like it should.
Here's the PHP - cURL code taken from Postman that I'm also using in my code. I've shortened certain strings for conciseness. The redirect_uri param is in CURLOPT_POSTFIELDS:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://account-d.docusign.com/oauth/token",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "grant_type=authorization_code&code=eyJ0eXAiOiJ...UDa8uJ9A&redirect_uri=http%3A//localhost/docusign/getData.php",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/x-www-form-urlencoded",
"Authorization: Basic NTYxN...DkxMA==",
"Cookie: __RequestVerificationToken=ARmOPr...tg0B0"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>
I've closely followed this DocuSign doc regarding following the authorization code grant flow: https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant
Any help is greatly appreciated!