DocuSign授权码授予流程返回invalid_grant错误 [英] DocuSign Authorization Code Grant flow returns invalid_grant error

查看:125
本文介绍了DocuSign授权码授予流程返回invalid_grant错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

DocuSign文档通过了易于遵循的授权流程代码授予。我可以从最初的GET请求到/ oath / auth获得代码,但是在尝试邮递员时获得令牌会给我一个错误 invalid_grant。我已按照步骤操作,并使用account-d.docusign.com作为主机发出了如下请求:

  POST /的OAuth /令牌
内容类型:应用/ X WWW的窗体-urlencoded
授权:基本MjMwNTQ2YTctOWM1NS00MGFkLThmYmYtYWYyMDVkNTQ5NGFkOjMwODc1NTVlLTBhMWMtNGFhOC1iMzI2LTY4MmM3YmYyNzZlOQ ==

grant_type = authorization_code&安培;代码= ey2dj3nd.AAAA39djasd3.dkn4449d21d

我们团队的另外两名成员也尝试使用其开发人员帐户,并且都收到invalid_grant错误。不再支持此功能吗?或者我们可以调查与该错误相关的常见错误?

解决方案

重新检查所有值。



我也得到了相同的 invalid_grant 响应,一开始却不知道为什么。事实证明,我在Content-Type标头中有一个错字。我使用的是 application / x-www-form-urlencode 而不是 application / x-www-form-urlencoded



您可能不是,但是如果要提交的确切标题标题(如您在问题中的此处所示)( MjMwNTQ2YTctOWM1NS00MGFkLThmYmYtYWYyMDVkNTQ5NGFkOjMwODc1NTVlLTBhMWMtNGFHY1YMZN = Y

这是其文档。如果使用在线base64decoder 对该字符串进行解码,则结果为230546a7-9c55-40ad-8fbf-af205d5494ad:3087555e -0a1c-4aa8-b326-682c7bf276e9。这与文档中的示例集成密钥和秘密相同。



通过编码 您的 集成密钥和机密( integrationKey:secret ),使用此在线base64encoder 。这样可以确保问题与集成密钥和机密的base64编码无关。一旦获得该价值,请确保您的授权在从本网站获得价值之前使用基本一词。 ( 基本base64stringFromOnlineEncoder



检查您在帖子正文中提交的代码是否为示例其文档中的代码。 ey2dj3nd.AAAA39djasd3.dkn4449d21d 其文档的示例代码。您可能只是在问题中使用它作为占位符,但如果您提交任何这些值,它将返回 invalid_grant 。确保您的帖子正文没有任何前导或尾随空格。


  1. 具有正确的内容类型集应用程序/ x-www-form-urlencoded

  2. 已设置正确的授权标头 Basic base64EncodedIntegrationKey:Secret

  3. 使用从/ oauth / auth到/ oauth / auth的GET请求中接收到的有效代码来使用正确的正文,并确保您没有使用问题中的值。

如果您仍然遇到问题 ,则表示您没有进行 用户应用程序 ,但正在执行 服务集成 ,您可以使用旧版身份验证来获取oAuth2令牌。



使用其他方法 旧版身份验证 用于服务集成



此方法不使用授权码。您将集成密钥,用户名和密码以JSON格式传递到X-DocuSign-Authentication标头中。


演示服务器:demo.docusign .net



生产服务器:www.docusign.net API



版本:v2




  POST https:// {server} / restapi / {apiVersion} / oauth2 / token 
内容-类型:application / x-www-form-urlencoded
X-DocuSign-Authentication:{ IntegratorKey: your_integrator_key, Password: docusign_account_password, Username: docusign_account_username}

grant_type = password& client_id = your_integrator_key&用户名= docusign_account_username& password = docusign_account_password& scope = api

如果您要构建一个用户应用程序,要求用户输入其docusign凭据以生成令牌,则该替代方法将对您不起作用。


The DocuSign documentation goes through an easy to follow authorization flow for code grant. I'm able to get the "code" from the initial GET request to /oath/auth but getting the tokens gives me an error of "invalid_grant" when I try in postman. I've followed the steps and have a request that looks like this using account-d.docusign.com for host:

POST /oauth/token
Content-Type: application/x-www-form-urlencoded
Authorization: Basic MjMwNTQ2YTctOWM1NS00MGFkLThmYmYtYWYyMDVkNTQ5NGFkOjMwODc1NTVlLTBhMWMtNGFhOC1iMzI2LTY4MmM3YmYyNzZlOQ==

grant_type=authorization_code&code=ey2dj3nd.AAAA39djasd3.dkn4449d21d

Two other members of my team have also tried with their developer accounts and all are getting invalid_grant errors. Is this no longer supported or are there common errors associated with this error that we might be able to investigate?

解决方案

Re-check all of your values.

I was also getting the same invalid_grant response and could not figure out why at first. It turns out that I had a typo in the Content-Type header. I was using application/x-www-form-urlencode instead of application/x-www-form-urlencoded.

You may not be, but if you are submitting the exact Authorization Header as you've posted it here in your question (MjMwNTQ2YTctOWM1NS00MGFkLThmYmYtYWYyMDVkNTQ5NGFkOjMwODc1NTVlLTBhMWMtNGFhOC1iMzI2LTY4MmM3YmYyNzZlOQ==) it will fail with that message.

That is the base64 value for the sample integration key and sample secret key provided in their documentation. If you decode that string with an online base64decoder it will result in 230546a7-9c55-40ad-8fbf-af205d5494ad:3087555e-0a1c-4aa8-b326-682c7bf276e9. This is the same sample integration key and secret in the documentation.

Check the Authorization header you are submitting by encoding your integration key and secret (integrationKey:secret) using this online base64encoder. This will make sure the issue isn't with your base64 encoding of your integration key and secret. Once you have that value make sure your Authorization uses the word Basic before the value you got from this website. (Basic base64stringFromOnlineEncoder)

Check that the code your are submitting in the body of the post is not the sample code from their documentation. ey2dj3nd.AAAA39djasd3.dkn4449d21d is the sample code from their documentation. You may just be using that in your question as a placeholder but if you are submitting any of those values it will return invalid_grant. Make sure that the body of your post does not have any leading or trailing spaces.

  1. Have the correct Content-Type set application/x-www-form-urlencoded
  2. Have the correct Authorization header set Basic base64EncodedIntegrationKey:Secret
  3. Have the correct body using the valid code received from the GET request to /oauth/auth with no leading or trailing spaces, making sure you're not using the values from your question.

If you are still having trouble and you are not doing a user application but are doing a service integration you can use Legacy Authentication to get your oAuth2 token.

Alternative Method using Legacy Authentication for Service Integrations

This method does not use a grant code. You pass in the integration key, username and password into the X-DocuSign-Authentication header in JSON format.

Demo Server: demo.docusign.net

Production Server: www.docusign.net API

Version: v2

POST https://{server}/restapi/{apiVersion}/oauth2/token
Content-Type: application/x-www-form-urlencoded
X-DocuSign-Authentication: {"IntegratorKey":"your_integrator_key","Password":"docusign_account_password","Username":"docusign_account_username"}

grant_type=password&client_id=your_integrator_key&username=docusign_account_username&password=docusign_account_password&scope=api

If you are building a user application that requires the user enter their docusign credentials to generate the token, this alternative will not work for you.

这篇关于DocuSign授权码授予流程返回invalid_grant错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆