-->

Error when creating JWT Token

2019-03-01 06:06发布

问题:

As I am on my way to switch from using the legacy header authentication method to the JWT Token method, I have used the following example found here.

However, I get the following error :

Error calling Login: {
  "errorCode": "PARTNER_AUTHENTICATION_FAILED",
  "message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
}

Below is my C# code.

string oauthBasePath = "account-d.docusign.com";
string privateKeyFilename = "./private.pem";
int expiresInHours = 1;

ApiClient apiClient = new ApiClient(docuSignUrl);
apiClient.ConfigureJwtAuthorizationFlow(
    "IntegratorKey",
    "USER ID GUID",
    oauthBasePath,
    privateKeyFilename,
    expiresInHours);
AuthenticationApi authApi = new AuthenticationApi(apiClient.Configuration);
return authApi.Login();

I have found this thread that shows the similar error but it doesn't seem resolved

Update 05/07/2018: I have validated the domain used in my account but I still get the same error message

Update 05/11/2018: When I use my code but that I replace the IntegratorKey, UserID and private key used in the DocuSign Unit Tests here, my code now works !? Hence, I can only conclude that the issue doesn't come from my code but maybe a configuration issue on the DocuSign side ? do I need to configure my Integrator Key a specific way ?

回答1:

After more investigation, the reason with such an error is that I was not generating the Authorization Code Grant prior to executing my code. Based on the information found here, I had to perform the following HTTPRequest example :

GET /oauth/auth?
  response_type=token
  &scope=signature
  &client_id=YOUR_INTERGRATOR_KEY
  &state=a39fh23hnf23
  &redirect_uri=http://www.example.com/callback

Once it is approved, then I can run my code successfully. In the end, the initial error message is really misleading (I might argue it could be considered a bug ?).