DocuSign JWT Grant流程给出了“ invalid_grant”错误

时间:2019-03-18 19:41:15

标签: docusignapi

是否有人遇到了本主题中提到的invalid_grant错误,该错误导致调用ApiClient.RequestJWTUserToken的错误?

这是我的电话。我已经验证了我的DSConfig字段的值。

private void UpdateToken()
    {
        ApiClient docusign_api = new ApiClient();
        DSConfig cfg = new DSConfig();
        const int jwtLifeSec = 10 * 60; // requested lifetime 
//for the JWT     is     10 min
        List<string> scopes = new List<string>();
            scopes.Add("signature");
 // impersonation scope is implied due to use of JWT grant

    OAuth.OAuthToken authToken = docusign_api.RequestJWTUserToken    (DSConfig.ClientID,
                    DSConfig.ImpersonatedUserGuid,
                    DSConfig.AuthServer,
                    Encoding.UTF8.GetBytes(DSConfig.PrivateKey),
                    jwtLifeSec, scopes);

        AccessToken = authToken.access_token;

        if (Account == null)
            Account = GetAccountInfo(authToken);

        docusign_api = new ApiClient(Account.BaseUri + "/restapi");

        expiresIn = DateTime.Now.Second + authToken.expires_in.Value;
    }

public OAuth.OAuthToken RequestJWTUserToken(string clientId, string userId, string oauthBasePath, byte[] privateKeyBytes, int expiresInHours, List<string> scopes = null);

1 个答案:

答案 0 :(得分:0)

好像您没有使用正确的参数。

第三个参数是scopes参数,而不是服务器。

对于Node.js,请尝试以下操作:

const jwtLifeSec = 10 * 60, // requested lifetime for the JWT is 10 min
      scopes = "signature", // impersonation scope is implied due to use of JWT grant
      dsApi = new docusign.ApiClient();

dsApi.setOAuthBasePath(dsConfig.authServer);
const results = await dsApi.requestJWTUserToken(dsConfig.clientId,
      dsConfig.impersonatedUserGuid, scopes, dsConfig.privateKey,
      jwtLifeSec);