I’m currently integrating DocuSign into my Rails application, and I’m encountering an issue when trying to obtain a JWT bearer token for authentication. Whenever I make a request to obtain the token, I receive the following error:
DocuSign_eSign::ApiError (Bad Request):
This error occurs within the get_jwt_bearer_token
method of my DocusignService
. Here’s the relevant code snippet:
def get_jwt_bearer_token
api_client.set_base_path(@base_path)
private_key_filename = File.join(Rails.root, 'config', 'docusign_private_key.txt')
expires_in_seconds = 3600 # Adjust as needed
scopes = ["signature", "impersonation"]
api_client.request_jwt_user_token(@integration_key, @user_id, private_key_filename, expires_in_seconds, $SCOPES.join('+'))
end
I’ve cross-checked my environment variables and I confirm that the environment variables DOCUSIGN_INTEGRATION_KEY
, DOCUSIGN_USER_ID
, and DOCUSIGN_ENDPOINT
are correctly set. Additionally, I’ve verified that the private key file exists at the specified path.
I’ve also included the relevant configuration from my .env file
DOCUSIGN_ENDPOINT=https://demo.docusign.net/restapi
BASE_URL=localhost:3000 DOCUSIGN_ACCOUNT_ID=239XX015
DOCUSIGN_INTEGRATION_KEY=9b53690f-1012-4XXf-a91b-c82635895b09
DOCUSIGN_USER_ID=95b81f2e-b0d6-4XXc-b429-eb40daXXb130
DOCUSIGN_AUTH_SERVER=account-d.docusign.com
Could anyone help me understand why I’m encountering this error and how I can resolve it?
Hira is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.