Load Test Express APIs (nodejs) using JMeter - jmeter

I am trying to load test Express Apis (nodejs) using Jmeter.
I am using passport to login.
I am able to login using JMeter but when I make another request which needs authorisation I am getting an error. I have a middleware to check authorisation where I am checking 'req.user'. But when using Jmeter req.user is undefined.
Can anyone tell me what am I missing or doing wrong?
Thanks
:)

Looking into Creating a Simple Node/Express API Authentication System with Passport and JWT article you are missing correlation - handling the dynamic authentication token, you need to do the following to work this around:
Send a HTTP Request to /authenticate endpoint
Extract the token using JSON Extractor
Add a HTTP Header Manager to the next HTTP Request and configure it to send Authorization header with the value of the token, extracted in step 2.

Related

Access GitHub API from Nifi

I'm trying to access info within GitHub's API from a NiFi Process. Essentially, I'm using GenerateFlowFile to set the target URL and the Authorization header for the token. I then pass it to the InvokeHTTP and every time it gets a 401 error saying it needs to be authenticated, despite providing my personal token (the one I use when programming locally and with Terminal). Any tips on how I can get this working? I can provide more detail if needed
I'm not sure which endpoint you're trying to access in the GitHub API, but it appears you are using an endpoint from GitHub Enterprise 2.22 from the error message.
The docs for authentication show you should prefix the token with token i.e:
Authorization: token OAUTH-TOKEN
In your specific case, this means you should set the Authorization header to token ${github_token}.

How to intercept an HTTP redirect response in Power Automate?

I have a Power App and Power Automate solution integrated with Docusign using their REST API's.
My issue is that I have users log into Docusign from a link which when completed and authenticated, returns an https response (authorization code) on the redirect uri. I want to be able to 'capture' the authorization code within Power Automate.
I want to avoid using custom connectors as they seem unreliable when using Oauth2 authentication and the users access token has expired. My preference is to use the HTTP REST API steps in Power Automate instead.
With a redirect to https://localhost:3000/auth/docusign/callback, I get the following https response:
https://localhost:3000/auth/docusign/callback?code=eyJ0eXAiOiJNVCIsImFsZyI6IlJTMjU2Iiwia2lkIjoiNjgxODVmZjEtNGU1MS00Y2U5LWFmMWMtNjg5ODEyMjAzMzE3In0.AQoAAAABAAYABwAAlzFclSfZSAgAACO4o5Un2UgCAOid-3Oz8jJHsDvIUG5hRR8VAAEAAAAYAAEAAAAFAAAADQAkAAAAZjA5Y2U4NDQtM2U5Yy00NjEzLTkwNzctNGY5MmFhY2NjZTc4IgAkAAAAZjA5Y2U4NDQtM2U5Yy00NjEzLTkwNzctNGY5MmFhY2NjZTc4NwBBDjKOCdhvSaNUWiI7O-21MAAAkAfAlCfZSA.zrYv2gsNFPVWHZpoO7-_5o4Ika3DxQpbNqlPUHiOvYFVL5igRnbZHh2V7OmN0bff7Tf14QF3pWaBAATozpIgzgj21m3ZjLbhY5J42eR1msXmoXjbBggibGC_FqbprVCzjSCvjbvMlwgEwda7LApdSWwr49ON9KhdN84qWD9sacJJvdi3Oi1KInImlVB_2rTpCLFhMD98PBv6b074yTqLOfwV31QT-6si8xLtk3G2vtn2gFZigXQxIA18b6tC-BM3NOILV1zwZNa1pstxxG2W8jJByUQlAux3d1GuS4vnDu_nr54mXULV0vY7txLFRiJA5w_E7Nlu2dlaOa5_DmfpNg
I want to intercept the code=eyJ0e........ in my flow.
I have tried setting up an http request and using the unique endpoint, used that as a redirect endpoint to send it to a receiving HTTP request flow. Docusign did not like the http request URL as a redirect.
I have to think this is a very simple thing to do and probably has to do with how the redirect/callback is configured in Power Automate. There maybe third party solutions that can act as a redirect intermediary which I can then GET with an API call. All ideas appreciated.

Getting response data as "Authentication credentials were not provided" in jmeter

I'm trying to automate one scenario after logging in. I have created one HTTP request for login and another for to do the action which is my scenario. For first HTTP request it is working fine and I'm able to login to application, when coming to second HTTP request it is showing response as "Authentication credentials were not provided". Please provide some reference.
After login to the application an API token will be generated. We need to use that for any further actions. So After login to your application look into response data and Verify the authentication token. Keep Regrex Extractor and copy that API Token and keep it in Request data.
Let me know if you have any queries.

JWT or OAuth or Both in LARAVEL WEB API

i'm building a WEB API with laravel and output only JSON. right now i'm struggling with authentication process, my question is:
if i use JWT do i need OAuth2.0?
if i use JWT do i need to make a view / layout for user to POST the login credential then set the Bearer token? if no need to provide a login screen then how can we get the login credential from user?
if i use JWT what is the standard TTL duration for real world api?
if i use JWT how can i passing the "refreshed token" to the HTTP Header Authorization, without using JS? (because i only output the JSON response then i think there is no space for javascript "< script >" tag to be in place.)
i am using postman to test my API so i really confuse about what or how to push the project into real world. PLEASE REALLY..., PLEASE correct me if i'm wrong developing the API and if there is any source of reading material please tell me the links. Thank you very much.
No.
No, you can send json fields.
No standard TTL duration, you can set what you like.
You can issue a request with HTTP Header Authorization in PHP.

Laravel: API with OAuth 2.0

I am currently developing an API that I plan to secure using oauth2.
I have chosen: https://github.com/lucadegasperi/oauth2-server-laravel/
I have managed to secure the endpoint (using before=>oauth in my api routes) by following the installation guide but I am at a loss as to how am I gonna be able to authenticate and access the endpoint.
I do understand that you will first need to request an access_token by sending a client_id and client_secret but what I don't get is where do I set those on the oauth server?
I see the oauth controller has endpoints for these like:
http://somedomain.com/oauth/authorize
http://somedomain.com/oauth/access_token
But I am clueless with what to do with them. I only managed to arrive at the conclusion that it needs a client_id, client_secret, and stuff about scopes.
Where can I set these values for the api client to use?
Thank you for your help in advance.
I don't know Laravel, but in general, the authorization endpoint (in your case, http://somedomain.com/oauth/authorize) behaves as described in RFC 6749.
The specification defines four flows. If you use Authorization Code Flow among the flows, you should access the authorization endpoint with the following request parameters.
response_type=code (required)
client_id={your-client-id} (required)
scope={space-delimited-scope-names} (optional)
redirect_uri={your-redirect-uri} (conditionally optional)
state={any-arbitrary-string} (optional)
For example,
http://somedomain.com/oauth/authorize?response_type=code&client_id=your-client-id&scope=profile+email
The authorization endpoint generates an authorization code and returns it to your browser.
The next step is to access the token endpoint (in your case, http://somedomain.com/oauth/access_token) with the authorization code which has been issued from the authorization endpoint. Like this,
POST
http://somedomain.com/oauth/access_token?grant_type=authorization_code&code=issued-authorization-code&client_id=your-client-id&client_secret=your-client-secret
Anyway, I recommend you read RFC 6749.

Resources