1

I have tried authentication using DocuSign API.

When I send the request using jQuery ajax, I keep getting the "Access-Control-Allow-Origin" Header error.

When I try with PHP curl, I don't get any response. Do you have any idea of the issue.??

If you need more details, you can ask in the comments. Thanks in advance.

Abhishek Kumawat
  • 780
  • 1
  • 10
  • 25
  • The DocuSign API does not support CORS so you won't be able to make the ajax calls. The cUrl request should work though, please share the details of the call you're making (ie URL, method, headers) – Ergin Nov 16 '17 at 18:24
  • I've put the code below. Kindly take a look and suggest me the solution. – Abhishek Kumawat Nov 17 '17 at 19:01
  • DocuSign via AJAX is not supported, see answer here: https://stackoverflow.com/questions/25518778/unable-to-login-in-docusign/25552955#25552955 (with a working php / ajax login call) – Andrew Nov 20 '17 at 03:15

2 Answers2

1

https://account-d.docusign.com/oauth/token&response_type=code&scope=signature&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&state=a39fh23hnf23&redirect_uri=https://www.google.com/ is not a REST URL, it is a browser interaction, you need to open browser to open this link, then you need to enter DocuSign credential of the person for whom you want to get the access token. If the authentication is successful, the authentication service redirects the user to the redirect_uri (browser to browser interaction). The callback contains a code that you will exchange for a token in the next step. With this code, you will use OAUTH REST API to get the access token. Details are available at https://docs.docusign.com/esign/guide/authentication/oa2_auth_code.html

The url which you are trying should only be accessed on a browser not using AJAX or any REST API tool, as it is a normal web application url. After you receive the code in the callback then you can use Rest Tool to get the access token. I hope before you started trying this flow, you have correctly setup the integrator Key with the redirect_uri and secretKey, as these two items will be required to get a successfull accesstoken.

Amit K Bist
  • 6,760
  • 1
  • 11
  • 26
0

Thanks for the reply Ergin. Here is what i tried.

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https://account-d.docusign.com/oauth/token&response_type=code&scope=signature&client_id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&state=a39fh23hnf23&redirect_uri=https://www.google.com/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_FOLLOWLOCATION => 1,
  CURLOPT_SSL_VERIFYHOST => false,
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "postman-token: a51a80ff-b741-3d19-4fd5-1099f034e1ae"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
   print_r($response);
}

I am not sure about what headers to use in here, but I've tried using the code from Postman and it still doesn't work. Thanks

Abhishek Kumawat
  • 780
  • 1
  • 10
  • 25