Sign in
agent:
Auto Exec

Generate Access Token for Docusign Integration App

There was a problem that the LLM was not able to address. Please rephrase your prompt and try again.

Create a JWT-based access token to authenticate and interact with the DocuSign API.

import requests import time import jwt # Configuration # To be received from the Input Parameters # integration_key = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" #docusign application key # user_id = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" # API User ID from DocuSign auth_server = "account-d.docusign.com" # Use "account-d.docusign.com" for demo developer accounts # private_key = """-----BEGIN RSA PRIVATE KEY----- # XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX # -----END RSA PRIVATE KEY-----""" # Create JWT token current_time = int(time.time()) payload = { "iss": integration_key, "sub": user_id, "aud": auth_server, "iat": current_time, # Issued at time "exp": current_time + 3600, # Token expiration (1 hour) "scope": "signature impersonation" } jwt_token = jwt.encode(payload, private_key, algorithm="RS256") # Request access token url = f"https://{auth_server}/oauth/token" headers = {"Content-Type": "application/x-www-form-urlencoded"} body = { "grant_type": "urn:ietf:params:oauth:grant-type:jwt-bearer", "assertion": jwt_token } response = requests.post(url, headers=headers, data=body) # Handle the response if response.status_code == 200: access_token = response.json()["access_token"] print("Access Token:", access_token) else: print("Error:", response.json())
copied