I have upgraded the DocuSign eSign NuGet package from 4.1.1 to the latest version 5.1.0 in my test project.
Test Code:
var auth = DocuSign.eSignature.JWTAuth.AuthenticateWithJWT();
string accessToken = auth.accessToken;
string accountId = auth.accountId;
string basePath = auth.baseUri;
var config = new Configuration(basePath);
config.AddDefaultHeader("Authorization", "Bearer " + accessToken);
EnvelopeDefinition envelope = MakeEnvelope("[email protected]", "User Name", "",
"", "15ffda8-5953-4e5f-b9d6-112133adf0e7");
var envelopesApi = new EnvelopesApi(new ApiClient(config));
EnvelopeSummary result = envelopesApi.CreateEnvelope(accountId, envelope);
However, since then I am receiving the following error when running the code:
DocuSign.eSign.Client.ApiException: 'Error calling CreateEnvelope: {"errorCode":"USER_AUTHENTICATION_FAILED","message":"One or both of Username and Password are invalid. Invalid access token"}'
I got the AuthenticateWithJWT() method from DocuSign:
public static (string accessToken, string accountId, string baseUri) AuthenticateWithJWT()
{
var apiClient = new ApiClient();
string ik = ConfigurationManager.AppSettings["IntegrationKey"];
string userId = ConfigurationManager.AppSettings["userId"];
string authServer = ConfigurationManager.AppSettings["AuthServer"];
string rsaKey = ConfigurationManager.AppSettings["RSAKey"];
OAuth.OAuthToken authToken = apiClient.RequestJWTUserToken(ik,
userId,
authServer,
Encoding.UTF8.GetBytes(rsaKey),
1);
string accessToken = authToken.access_token;
apiClient.SetOAuthBasePath(authServer);
OAuth.UserInfo userInfo = apiClient.GetUserInfo(authToken.access_token);
Account acct = null;
var accounts = userInfo.Accounts;
{
acct = accounts.FirstOrDefault(a => a.IsDefault == "true");
}
string accountId = acct.AccountId;
string baseUri = acct.BaseUri + "/restapi";
return (accessToken, accountId, baseUri);
}
It is correctly returning my accountId, an access token, and a base path just like before.
Any ideas on what might be causing this error or what steps I might take to troubleshoot this further?