EsperoTech / yaade

Yaade is an open-source, self-hosted, collaborative API development environment.
MIT License
1.59k stars 70 forks source link

Question: How to test an API with credentials? #208

Open jhjacobs81 opened 1 day ago

jhjacobs81 commented 1 day ago

Is it possible to test an api with credentials? so i can post my login details to /api/login and have it saved for future testing?

Or maybe i am overlooking something?

jonrosner commented 1 day ago

What kind of authentication system do you use? If you use something token based than you can simply store the token in an environment.

jhjacobs81 commented 13 hours ago

hello Jon, thank you for responding :)

currently i do this: curl -c cookies.txt -X POST http://127.0.0.1:8080/login -H "Content-Type: application/json" -d '{ "Username": "user", "Password": "password" }'

which will generate a cookies.txt like this: 127.0.0.1:8080 FALSE / TRUE 1733555692 AppName MTczMDk2MzY5M3xEWDhFQVFMX2dBQUJFQUVRQUFBZl80QUFBUVp6ZEhKcGJtY01DUUFIZFhObGNsOXBaQVIxYVc1MEJnSUFHQT09fLtMohuQTYQ_xjDYdRxghTX1E_2NRVIyfgtvCnppCpbW

and then on subsequent request i do this: curl -b cookies.txt -X POST http://127.0.0.1:8080/create -H "Content-Type: application/json" -d '{ "Username": "user1", "Password": "userpass" }'

its a session based webapp