DocuSign API - JWT token generation API nodejs - node.js

I'm having trouble generating toke access with jwt docusign documentation is very confusing. Does anyone have an example in nodejs.
I already got an example in the directory but it's presented a lot of error.
https://github.com/docusign/code-examples-node
Does anyone have an example I can follow?

Related

JWT : How do I renew JWT without using jwt.io

My DocuSign App failed the "Go Live Review" due to me not using OAuth 2.0 authentication.
I have now read the documentation on how to "Get an access token with JWT Authentication" below:
https://developers.docusign.com/platform/auth/jwt/jwt-get-token/
Following this documentation I am able to get the JWT using jwt.io as suggested.
The Verified Signature code from jwt.io is then used to exchange for an DocuSign access_token using POSTMAN.
All this works as expected.
After some time the Verified Signature optained from jwt.io expires and calling https://account-d.docusign.com/oauth/token from POSTMAN results in this error:
{
"error": "invalid_grant",
"error_description": "expired_grant"
}
To fix this, I simply go to jwt.io and update the Payload section with new values for "iat" and "ext" and a new Verified Signature is obtained and copied in to POSTMAN for new request of access_token.
My question:
How to solve this expiring issue as DocuSign endpoint does not provide a refresh_token ?
It must be possible to somehow "renew" the Verified Signature as DocuSign endpoint requires this updated value for the field : "assertion" in POSTMAN.
I have tried to construct the three values separated by a period in the Verified Signature manually by base64 encoding, but I can´t figure out how to get the final RSASHA256 value in the Verified Signature.
I have seen the documentation for "Migrate to OAuth 2.0 using the DocuSign eSignature C#SDK" on this link :
https://developers.docusign.com/platform/auth/oauth2-requirements-migration/
Please note that I am not a developer and maybee the solution to my question is obvious for real developers - but I need a bit of help to solve this as I do not work in development-tool as shown on the video.
Please help...
How to solve this expiring issue as DocuSign endpoint does not provide a refresh_token?
The best is to create a new JWT for each OAuth call to DocuSign--and use software, not a website, to do so.
Note: Only obtain a new access token (by sending a fresh JWT) when the old access token has expired or is about to expire.
The DocuSign SDKs include functions to create a JWT. All of the SDKs are open source, so if you don't want to use the SDK as a whole, you can copy out the functions' implementations.
This would depend on what language your app is written in or what kind of tool it's built on. Generally, most programming languages have libraries that can generate the JWT for you without having to use jwt.io manually.
Does your app only make API calls via postman? This post might be helpful for you. It shows how to set up a pre-request script to generate the JWT

Using passport-docusign on nodejs

I am attempting to connect docusign on my app using nodejs and passport.
Requirements:
the docusign authentification is required only for few actions
a user can have multiple docusign connections
I would like to store the docusign token on my db, not only in session
Context:
I have already an other strategy with passport to authenticate my users (using bearer token in the headers of each request).
Is the library passport-docusign really suitable for these requirements or
it makes more sense to create something custom?
Someone which has the experience of this kind of use case would have any advice on it? 🙏
The passport-docusign strategy for passport is pretty vanilla.
If passport works for your use case, then the passport-docusign strategy should be of help with implementing the authorize code grant flow.
If you find changes/updates that could be made to the passport-docusign strategy, please add an issue or pull request to the repo.
Thank you.

How to pass basic authentication to API call in robotframework

I am trying to learn robot framework and I am trying to connect my https API using BASIC authentication. Can anyone help me to start with initial setup ?
Attached is the screenshot how Iam currently connecting the REST API.
An example I found on GITHUB looked promising but no idea how to use it in my case. https://github.com/jjwong/RESTinstance_starter_project/blob/master/tests/test_basic_authentication.robot
You might need to add your username and password in headers of your request like
Authorization Basic username:password
Note you need to encode it with base64.
In case of Token based authentication
Authorization Bearer ${jwt_token}

Generate token after login nodejs API

I am creating an API using nodejs and express. I need to provide local username/password authentication. I may need to provide additional authentication in the future so I am using passportjs as it seems the most flexible/plug-able.
The API will be used by a web application as well as a mobile application. Instead of having to pass the username/password with every single api request I was thinking I could let the user login and provide the client with a token. The client can store the token and provide that on each api request.
I have looked at using JWT tokens ie, http://coderead.wordpress.com/2012/08/16/securing-node-js-restful-services-with-jwt-tokens/. However I am not really sure how to create a secure token with JWT. I have read that using the username in a token is a bad idea. Has anyone use JWT in node to create tokens. Got an example?
Any other modules for node that I can take a look at for token generation.
node-uuid is the module you are looking for. I use it to authenticate the users and any task that requires a random and unique identifier. Encoding the credentials in the token is generally a bad idea.
It was already built into nodes crypto pacakge.
http://nodejs.org/api/crypto.html#crypto_crypto_randombytes_size_callback

Problem with FourSquare API calling after OAuth in iOS

I am facing this problem while trying to use FourSquare API with iPhone.
I am doing OAuth initially for getting tokens. So, now I have my application's client id & client secret. And oauth token & oauth token secret for the user. I am using this:
https://github.com/jdg/oauthconsumer
However, I am not sure how to proceed from here to calling the APIs. I mean, if I do this -
https://api.foursquare.com/v2/venues.json?geolat=-78.695548&geolong=35.767138&l=10&oauth_token=OAUTH_TOKEN
I am getting this reply:
{"meta":{"code":401,"errorType":"invalid_auth","errorDetail":"OAuth token not found or has been revoked."},"response":{}}
Can anyone please tell me what am I doing wrong here ?
Thanks.
-
ahsan
Please try this sample code and intgrate it in your code to get the correct access token
https://github.com/drewvergara/Foursquare-OAuth-iPhone

Resources