我正在生成DocuSign JWT访问令牌时出现错误:“consent_required”。

huangapple go评论145阅读模式
英文:

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

英文:

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.

huangapple
  • 本文由 发表于 2023年6月21日 22:54:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/76524632.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定