zion
zion

Reputation: 421

docusign - USER_DOES_NOT_BELONG_TO_SPECIFIED_ACCOUNT, User has already provided consent

I created a dummy account, through which I gave consent for main account APP.

I saved the UUID in the DB once authorized.

I created a JWT token using the APP integration key, UUID stored in the DB. Using following code

let apiClient = new Docusign.ApiClient();
apiClient.setOAuthBasePath(dsConfig.dsOauthServer.replace('https://', ''));  
const res = await apiClient.requestJWTUserToken(
    integratorKey, 
    uuid, 
    "impersonation signature", 
    rsaKey.toString(), 
    3600
);

Using the main accounts accountId, I'm trying to create an envelope where I'm receiving this error about USER_DOES_NOT_BELON_TO_SPECIFIED_ACCOUNT.

let dsApiClient = new Docusign.ApiClient();
    dsApiClient.setBasePath(dsConfig.dsBaseUri);
    dsApiClient.addDefaultHeader('Authorization', 'Bearer ' + jwt);

let envelopesApi = new Docusign.EnvelopesApi(dsApiClient)
  , results = null;

results = await envelopesApi.createEnvelope(dsConfig.accountId, {
    envelopeDefinition: envelope
});

Here -

dsConfig.dsOauthServer > 'https://account-d.docusign.com'
dsConfig.dsBaseUri > 'https://demo.docusign.net/restapi'

In the dummy account, I checked the consent is there in Manage Profiles/ Connected Apps.

This is all happening in sandbox developer accounts.

Please help

Upvotes: 0

Views: 150

Answers (1)

Inbar Gazit
Inbar Gazit

Reputation: 14015

AccountId and userId are not the same. Note that account is a higher-level object and one account can have many users. You must use the same account and user for that account. Meaning your dsConfig.accountId value is the GUID for the account in which the uuid you used for the token is a member.

This error means that DocuSign didn't find the user for which you authenticated in the account ID you provided as part of the API call to create an envelope.

Upvotes: 1

Related Questions