0

I am following the same code as in Examplebase class to get the JWT token and it suppose to renew the token after the token expired, but instead I am getting the following error after sometime.

below is the github link

https://github.com/docusign/eg-01-java-jwt/blob/master/src/main/java/com/docusign/example/jwt/ExampleBase.java

com.docusign.esign.client.ApiException: Error while requesting server, received a non successful HTTP code 401 with response Body: '{

"errorCode": "USER_AUTHENTICATION_FAILED",
"message": "One or both of Username and Password are invalid. Invalid access token"
}'
at com.docusign.esign.client.ApiClient.invokeAPI(ApiClient.java:1053)
at com.docusign.esign.api.EnvelopesApi.createEnvelope(EnvelopesApi.java:701)
at com.docusign.esign.api.EnvelopesApi.createEnvelope(EnvelopesApi.java:651)
Munish Chouhan
  • 318
  • 4
  • 10

3 Answers3

1

Are you calling check_token before each call to the DocuSign API? The check_token method checks the token expiration and then should generate a new one if the old one is about to expire.

Since JWT tokens only last an hour, it is not too hard to create a token then debug 55 minutes later. With a 10 minute buffer time, line 37 in the code should be triggered to create a new token at that time.

Larry K
  • 47,808
  • 15
  • 87
  • 140
0

Not sure what you mean by "it suppose to renew the token after the token expired" this you need to write code for. It's not happening automatically. If you use the same token you originally obtained (and it worked before) after 8 hours it will no longer work. I am assuming that's what is happening here. You need to use the refresh token to obtain a new token at that point.

Inbar Gazit
  • 12,566
  • 1
  • 16
  • 23
  • I meant in the check function it checks for expiry time and update the token again. Please explain how you get that 8 hours. – Munish Chouhan Sep 05 '19 at 16:24
  • DocuSign tokens expire after 8 hours. That's the design. – Inbar Gazit Sep 05 '19 at 16:26
  • https://medium.com/brandsoft/using-a-refresh-token-to-obtain-an-access-token-from-docusign-3c297eb51886 this article explains how to obtain a new token using a refresh token – Inbar Gazit Sep 05 '19 at 16:27
  • This article is about Authorization Code Grant Flow, but I am talking about JSON Web Token (JWT) Grant and in Examplebase class the expiration time is 1 hour. – Munish Chouhan Sep 06 '19 at 02:36
  • the tokens are always for 8 hours regardless of what authorization flow you used. – Inbar Gazit Sep 06 '19 at 15:08
0

Solved the Error using the answer given in the following question, please check there Docusign API's failing after an hour

Munish Chouhan
  • 318
  • 4
  • 10