英文:
I am { "error": "consent_required" } while generating the docusign JWT access token
问题
I am currently your Chinese translator, and I will only translate the provided code snippet. Here it is:
private_key = OpenSSL::PKey::RSA.new(@config[:rsa_private_key])
jwt_payload = { iss: @config[:integration_key],
sub: @config[:user_id], iat: Time.now.to_i,
exp: Time.now.to_i + 3600,
aud: 'account-d.docusign.com',
scope: 'signature'
}
response = HTTParty.post('https://account-id.docusign./oauth/token', body: { grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion: JWT.encode(jwt_payload, private_key, 'RS256') })
If you have any other requests, please let me know.
英文:
private_key = OpenSSL::PKey::RSA.new(@config[:rsa_private_key])
jwt_payload = { iss: @config[:integration_key],
sub: @config[:user_id], iat: Time.now.to_i,
exp: Time.now.to_i + 3600,
aud: 'account-d.docusign.com',
scope: 'signature'
}
response = HTTParty.post('https://account-id.docusign./oauth/token', body: { grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer', assertion: JWT.encode(jwt_payload, private_key, 'RS256') })
I am using the above code with valid credentials to generate the docusign jwt token.
but it giving "consent_required" error.
previously same was working fine. but not working now.
答案1
得分: 1
你的负载不正确。
请检查你的 gem 文件,你可能误删除了 JWT gem。
尝试以下代码:
private_key = OpenSSL::PKey::RSA.new(File.read('path/to/private_key.pem'))
jwt_payload = {
iss: @config[:integration_key],
sub: @config[:user_id],
iat: Time.now.to_i,
exp: Time.now.to_i + 3600,
aud: 'account-d.docusign.com',
scope: 'signature'
}
jwt_token = JWT.encode(jwt_payload, private_key, 'RS256')
请注意,这段代码假设你已经正确配置了 (@config) 并且有适当的私钥文件用于签署令牌。
生成令牌后,你可以将其直接传递给 API 请求。
英文:
Your Payload is not correct.
and do check your gem file you might have mistakenly removed the JWT gem.
try this:
private_key=OpenSSL::PKey::RSA.new(File.read('path/to/private_key.pem'))
jwt_payload = {
iss: @config[:integration_key],
sub: @config[:user_id],
iat: Time.now.to_i,
exp: Time.now.to_i + 3600,
aud: 'account-d.docusign.com',
scope: 'signature'
}
jwt_token = JWT.encode(jwt_payload, private_key, 'RS256')
Please note that this code assumes you have the necessary configurations (@config) in place and that you have the appropriate private key file for signing the token.
After generating the token, then you can pass it to the API request directly.
答案2
得分: 0
- JWT的作用域应该是"signature impersonation"
- 正确的URL用于认证是account-d.docusign.com
- 即使您按照上述正确操作,仍然需要获得同意,一旦出现用户/IK组合。在这篇文章中了解如何操作 - https://developers.docusign.com/platform/auth/consent/obtaining-individual-consent/
- 对于Ruby的JWT代码,我强烈建议您尝试快速入门,选择"Ruby"和"JWT",这将确保您获得一个配置正确且可正常工作的代码。
英文:
- scopes should be "signature impersonation" for JWT
- The correct URL is account-d.docusign.com for authentication
- Even if you do the above right, consent is still required, once pers user/IK combination. Read how to do it in this article - https://developers.docusign.com/platform/auth/consent/obtaining-individual-consent/
For Ruby code for JWT, I highly suggest you try quickstart and pick "Ruby" and "JWT" which will ensure you get a working configured code that just works.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论