从DocuSign API请求访问令牌时收到400错误的请求消息

编程入门 行业动态 更新时间:2024-10-28 18:33:07
本文介绍了从DocuSign API请求访问令牌时收到400错误的请求消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我可以通过使用链接 https://developers.docusign来生成docusign网站的访问令牌 / oauth-token-generator

但是,当尝试使用c#代码在我们的系统中获取访问令牌时,却收到消息(远程服务器返回了错误:(400)错误的请求。)

But when try to get access token in our system using c# code then getting message (The remote server returned an error: (400) Bad Request.)

我遵循以下链接中提到的身份验证过程。

I follow the authenticate process mentioned in below link.

developers.docusign/esign-rest- api / guides / authentication / oauth2-code-grant

我能够获取验证码。我使用了此身份验证代码来访问API( account-d.docusign/oauth / token )。

I able to get authentication code. I used this authentication code to hit API (account-d.docusign/oauth/token).

下面是我的代码示例

string integrationKey = "key removed"; string secretKey = "key removed"; var httpWebRequest = (HttpWebRequest)WebRequest.Create("account-d.docusign/oauth/token"); httpWebRequest.ContentType = "application/x-www-form-urlencoded"; httpWebRequest.Method = "POST"; string apiStoreConsumer = "removed"; httpWebRequest.Headers.Add("Authorization", "Basic " + apiStoreConsumer); using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream())) { string input = "authorization_code&authorization_code= <authentication code goes here>; streamWriter.Write(input); streamWriter.Flush(); streamWriter.Close(); } WebResponse response = (HttpWebResponse)httpWebRequest.GetResponse();

查询:

为什么会出现400错误?我们是否有访问令牌的到期时间,如果是,那么需要多长时间?身份验证代码是否对每个请求都有效?

Why am I getting 400 error? Do we have any expiry time for access token, if yes then how long? Does authentication code get change for every request?

请帮助我。

谢谢!

推荐答案

我建议您在.NET / C#中使用OAuth库如果您想了解操作方法,请克隆此仓库。 问题是您需要首先获取代码,然后进行交换e作为令牌。如果您手动进行,则涉及两个步骤。 第一步需要您在浏览器中对用户进行身份验证,然后才能调用任何API。 在此步骤中,您需要传递集成密钥并重定向回您的URL。 重定向回后,您将收到一个代码,可以使用您讨论的API调用将其交换为访问令牌。

I recommend you use a library for OAuth in .NET/C#. If you want to see how this is done, please clone this repo. The issue is that you need to first get a code and then exchange it for a token. There are 2 steps involved if you do this manually. The first step requires you to authenticate the user in a browser before you can call any API. During that step you need to pass in your integration key and redirect back to your URL. Once redirected back you'll receive a code that can be exchanged for an access token using the API call you had talks about.

更多推荐

从DocuSign API请求访问令牌时收到400错误的请求消息

本文发布于:2023-10-12 02:33:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483513.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:令牌   错误   消息   DocuSign   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!