创建JWT令牌时出错

时间:2018-02-06 01:03:18

标签: c# docusignapi

当我开始使用legacy header authentication方法切换到JWT Token方法时,我使用了以下示例here

但是,我收到以下错误:

Error calling Login: {
  "errorCode": "PARTNER_AUTHENTICATION_FAILED",
  "message": "The specified Integrator Key was not found or is disabled. An Integrator key was not specified."
}

下面是我的C#代码。

string oauthBasePath = "account-d.docusign.com";
string privateKeyFilename = "./private.pem";
int expiresInHours = 1;

ApiClient apiClient = new ApiClient(docuSignUrl);
apiClient.ConfigureJwtAuthorizationFlow(
    "IntegratorKey",
    "USER ID GUID",
    oauthBasePath,
    privateKeyFilename,
    expiresInHours);
AuthenticationApi authApi = new AuthenticationApi(apiClient.Configuration);
return authApi.Login();

我发现this thread显示了类似的错误,但似乎没有解决

更新05/07/2018:我已经验证了我帐户中使用的域名,但我仍然收到相同的错误消息

更新05/11/2018:当我使用我的代码但我替换了DocuSign单元测试here中使用的IntegratorKey,UserID和私钥时,我的代码现在可以使用了!因此,我只能得出结论,问题不是来自我的代码,但可能是DocuSign方面的配置问题?我是否需要以特定方式配置Integrator Key?

1 个答案:

答案 0 :(得分:0)

经过更多调查后,出现这种错误的原因是我在执行代码之前没有生成授权代码授权。 根据找到的信息here,我必须执行以下HTTPRequest示例:

GET /oauth/auth?
  response_type=token
  &scope=signature
  &client_id=YOUR_INTERGRATOR_KEY
  &state=a39fh23hnf23
  &redirect_uri=http://www.example.com/callback

一旦获得批准,我就可以成功运行我的代码。 最后,最初的错误信息确实具有误导性(我可能认为它可能被认为是一个错误?)。