生成DocuSign访问令牌在Rails中,无需通过浏览器进行授权码。

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

Generating DocuSign access token in Rails without authorization code via browser

问题

我正在Rails项目中进行DocuSign集成。要使用envelope_apis,我需要access_token。但是为了生成access_token,我需要authorization_code,可以通过在浏览器中访问以下URL获取:https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature&client_id={{clint_id}}&redirect_uri=http://www.example.com/callback。然后,我必须输入帐户ID和密码。在完成上述过程后,我会获得用于access_token API的authorization_code。此外,Access_Token有效期为8小时。在Rails中,我们如何解决这个问题?

我已经尝试了上述过程来生成access_token,但我想找到一种方法,可以避免通过浏览器生成authorization_code。

英文:

I am working on docuSign integration in rails project.
for using the envelope_apis i need access_token. But for generating the access_token i need authorization_code that we can get by putting this url in browser https://account-d.docusign.com/oauth/auth?response_type=code&scope=signature&client_id={{clint_id}}&redirect_uri=http://www.example.com/callback.
Then i have to enter the account id & password. After all above process i am getting the authorization_code for access_token api. Also Access_Token valid for 8 hrs.
How we can solve this problem in rails.

I have tried above process to generate the access_token but i want a solution thorugh with i can avoid the authorization_code generation process through the browser.

答案1

得分: 0

以下是翻译好的部分:

唯一的选择是使用JWT,JWT允许您生成代码而无需任何用户交互,无需登录到DocuSign。

您需要一次性同意,其中包括允许您的应用模拟用户的“模拟”范围(因为用户不会亲自登录),但这只需要一次,如果您愿意,可以手动完成,然后您可以使用Ruby SDK 调用此方法来获取访问令牌:

token = api_client.request_jwt_user_token(Rails.configuration.jwt_integration_key, Rails.configuration.impersonated_user_guid, rsa_pk, 3600, @scope)
英文:

The only option is to use JWT, JWT allows you to have the code generated without any user interaction, without having to login to DocuSign.
You need a one-time consent that includes the "impersonation" scope that allow your app to impersonate the user (Since the user won't be in there in person logging in) but this is just needed once, can be done manually if you want and then you can just use the Ruby SDK to call this method to get an access token:

 token = api_client.request_jwt_user_token(Rails.configuration.jwt_integration_key, Rails.configuration.impersonated_user_guid, rsa_pk, 3600, @scope)

huangapple
  • 本文由 发表于 2023年6月1日 00:11:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76375469.html
匿名

发表评论

匿名网友

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

确定