Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

docusignapi - How to use `DocuSign.eSign.Client.ApiClient.RequestJWTApplicationToken`

I'm trying use method RequestJWTApplicationToken to authenticate and create a envelope, like the code below:


private OAuthToken _authToken;
protected static ApiClient _apiClient { get; private set; }


public string GetToken()
{
    _authToken = _apiClient.RequestJWTApplicationToken(
        "<ClientId>",
        "<AuthServer>",
        "<PrivateKeyBytes>",
        1,
        "<Scopes>");
}

public void SendDocumentForSignature()
{
    var envelope = MakeEnvelope("[email protected]", "my name");
    
    var token = GetToken();

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

    apiClient.Configuration.DefaultHeader.Add("Authorization", "Bearer " + token);
    var envelopesApi = new EnvelopesApi(apiClient);
    EnvelopeSummary results = envelopesApi.CreateEnvelope("<AccountId>", envelope);

    string envelopeId = results.EnvelopeId;
}

But I received the exception below, here envelopesApi.CreateEnvelope("<AccountId>", envelope);:

Error calling CreateEnvelope: {"errorCode":"AUTHORIZATION_INVALID_TOKEN","message":"The access token provided is expired, revoked or malformed. Authentication for System Application failed."

I didn't find any use cases about the RequestJWTApplicationToken method in the documentation or in the" Quick Start "project.

question from:https://stackoverflow.com/questions/65924321/how-to-use-docusign-esign-client-apiclient-requestjwtapplicationtoken

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The RequestJWTApplicationToken can only be used with a very few DocuSign API methods related to organization management. All of of the eSignature REST API methods require an access token that is associated with a user in an account.

To create such access tokens using the OAuth JWT flow, use the C# RequestJWTUserToken method.

The associated user for some use cases is a "system user" such as "[email protected]" For other use cases, the user will be a specific named user.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...