Zeeshan Adil
Zeeshan Adil

Reputation: 2125

apiClient.RequestJWTUserToken in docusign doesn't work

I'm using DocuSign C# SDK to create a JWT token to impersonate as a user using an Integrator key but it throws an error saying:

Error while requesting server, received a non-successful HTTP code

I'm simply calling the UpdateToken() method which is like this:

 private static void UpdateToken()
        {
            var apiClient = new ApiClient();

            OAuth.OAuthToken authToken = apiClient.RequestJWTUserToken(ClientID, ImpersonatedUserGuid, AuthServer, Encoding.ASCII.GetBytes(PrivateKey), TokenExpiryInHours, new List<string> { "signature", "impersonation" });

            AccessToken = authToken.access_token;

            TokenExpiryTime = DateTime.Now.AddSeconds(authToken.expires_in.Value);
        }

values for all the parameters passed in RequestJWTUserTokenare:

 "DocuSign": {       
    "ClientID": "aff67220-XXXX-XXXX-XXXX-426b6575c3bd",
    "ImpersonatedUserGuid": "f9a0f822-XXXX-XXXX-XXXX-7a576f06df81",
    "AuthServer": "https://account-d.docusign.com",
    "TokenReplacementTimeInSeconds": "600",
    "TokenExpiryInHours": "1",
    "PrivateKey": "-----BEGIN RSA PRIVATE KEY-----\r\XXXXXXX\r\n-----END RSA PRIVATE KEY-----"
  }

I have taken the consent from the user by using this endpoint:

https://account-d.docusign.com/oauth/auth? response_type=token&scope=signature%20impersonation&client_id=aff67220-3ca7-4de7-8556-426b6575c3bd &redirect_uri=https://www.vava.cars/tr/admin

and the user has successfully allowed this clientId/integrator key to have the permissions.

I don't know what I am doing wrong here.

Upvotes: 2

Views: 3687

Answers (1)

Drew
Drew

Reputation: 5029

For the Audience value (AuthServer in your code), you need to drop the https:// prefix and set that to account-d.docusign.com

Upvotes: 6

Related Questions