docusign / docusign-esign-csharp-client

The Official DocuSign C# Client Library used to interact with the eSignature REST API. Send, sign, and approve documents using this client.
https://developers.docusign.com/
MIT License
128 stars 157 forks source link

Error while requesting server, received a non successful HTTP code with response Body: {"error":"consent_required"} #366

Open Tushar5283 opened 2 years ago

Tushar5283 commented 2 years ago

I am following below code and getting the consent required error. Please suggest the solution,

var apiClient = new ApiClient("https://demo.docusign.net/restapi");

        string ik = "xxxxxxxxxxxxxxxxxxxxxxx";
        string userId = "xxxxxxxxxxxxxxxx";
        string authServer = "account-d.docusign.com";
        string rsaKey = File.ReadAllText(@"C:\WorkArea\DocuSignProj\DocuSignProj\Doc\pass.txt");

        List<string> scopes = new List<string>
        {
            "impersonation"
        };

        OAuth.OAuthToken authToken = apiClient.RequestJWTUserToken(ik, userId, authServer, Encoding.UTF8.GetBytes(rsaKey), 1, scopes);

        string accessToken = authToken.access_token;
karankaushik95 commented 2 years ago

Have you granted consent to your app before requesting the auth token? JWT requires the user to grant consent once per app based on the Integration Key. Step 1 of this guide describes how to grant consent for your app.