Auto Refresh DocuSign Token

Peter Xiang
Tera Expert

Hi,

I have configured the DocuSign Spoke according to the document content.

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0852804

https://docs.servicenow.com/bundle/rome-servicenow-platform/page/administer/integrationhub-store-spo...

And I have also got the token of DocuSign, but this token will expire after one hour, I would like to know if there is any way to automatically update this token instead of manually updating it every time, thanks.

PeterXiang_0-1688458323692.png

PeterXiang_1-1688458337465.png

 

1 REPLY 1

Laszlo Balla
ServiceNow Employee
ServiceNow Employee

For a similar integration I am doing the following:

  1. Created an API Key Credential record [api_key_credentials] --> the token will be stored
  2. I store the token in the 'api_key' field of this credential record, which is 2 way encrypted.
  3. I have a flow (could be scheduled job as well, but for us the integration is built as a custom IntegrationHub spoke too) which runs every 30 minutes and refreshes the token. By refresh, I mean:
    1. Send a REST request to an endpoint with basic auth to get the token
    2. Parse the response header that stores the token
    3. Encrypt the token (as it is scoped, it is done with gs.base64Encode())
    4. Update the api_key field of the credential record with the encrypted string
  4. Any other custom actions I have with a REST step that needs the token can simply take it from the API Key Credential record, decode and use it (much better performance then requesting a token every time).

Hope it helps or gives you some ideas to create your own solution.