1
votes

I've seen a couple questions on this asked on StackOverflow, but none have helped me. I can not get past the 'invalid_grant' error when trying to do an Authorize Code Grant on my 1 admin user in Docusign Sandbox environment.

I have 1 user, who is a DS Admin in the dashboard I created a new App and obtained the Integrator Key/client_id and Secret Key

Using the guide, https://developers.docusign.com/esign-rest-api/guides/authentication/oauth2-code-grant

I have successfully called and granted permission to the user with

https://account-d.docusign.com/oauth/auth? response_type=code&scope=signature%20impersonation&client_id=INTEGRATOR KEY&redirect_uri=https://www.docusign.com

and obtained the code returned

I have taken the Integrator Key and secret key, in form INTEGRATOR_KEY:SECRET_KEY and base64 encoded it.

I have tried using Postman and just straight up cURL call to obtain the access token. I have done this numerous times, with numerous new Apps created in Docusign Sandbox. They all return invalid_grant error.

cURL call

curl --header "Authorization: Basic BASE64ENCODING(INTEGRATOR_KEY:SECRET_KEY)" --data "grant_type=authorization_code&code=CODE_RETURNED_FROM_PERMISSION_GRANT" --request POST https://account-d.docusign.com/oauth/token

2
Are you trying to implement the JWT flow or the Authorization Code Grant flow? Your question says you're trying to "obtain the jwt token." Did you mean the Access Token?Larry K
@LarryK yes, Access Token. Updatedndyr

2 Answers

1
votes

The Authorization Code you receive back from DocuSign is only good for a couple of minutes. If you try to use it after that time then you'll receive the invalid grant error.

Also, if you are doing the Authorization Code Grant flow then you should not be requesting the impersonation scope. -- It is only for the JWT flow.

2
votes

It's possible that DocuSign isn't able to correctly interpret your request because you're missing a Content-Type header.

Try adding Content-Type: application/x-www-form-urlencoded