docusign / code-examples-node

Node.js code examples and launcher
https://developers.docusign.com/
MIT License
62 stars 52 forks source link

Authorization Code Grant with JWT - is it possible? #21

Closed cmosgh closed 4 years ago

cmosgh commented 4 years ago

I have a situation where I was forced to switch from Implicit Grant to Authorization Code Grant. Is it possible to use docusign-esign lib requestJWTUserToken method to generate token for an integration that was setup with Authorization Code Grant ?

AaronWDS commented 4 years ago

Hello @cmosgh, you could use requestJWTUserToken in lieu of Authorization Code grant but will still need to obtain consent authorization on the first time attempting to login with requestJWTUserToken. If your use case allows you to obtain consent in advance or such that you can route your user to login and accept consent for account impersonation on that first use, then you can use the same token generated for your integration. See a detailed blog post we've published on obtaining consent for more details or you can see how this application handles jwt consent also. Thanks for reaching out!

LarryKlugerDS commented 4 years ago

Hi @cmosgh, I'd add that it is not a big deal to switch from implicit to authorization code grant. You can use the Passport library along with the passport-docusign repo.

We recommend either authorize code grant or implicit grant if the user is present.

Remember that you can use extended scope so you don't need to ask the user to re-authenticate a second time.

cmosgh commented 3 years ago

Thank you @LarryKlugerDS and @AaronWDS for the help. Eventually I managed to make it work.

I am not using passport tho but the example repo helped me out integrating it properly.