So first, let me show you by example how Craigslist is actually authenticating us when we log in.
Click on the my account up here and then you need to make an account with your email first and then
we can try out and see how we authenticate ourselves.
So press command option I.
Or control shift.
I.
If you're on windows to open up the chrome developer menu.
Go inside the network tab here.
And make sure that you have preserved log enabled.
So it doesn't clear the log when the page is reloading or you get navigated to another page as you log
in.
Then click on the recording button, make sure it's recording, and then try and click on log in.
So here we go.
And now I'm logged in and then I'm going to stop the recording so I don't get more requests in my log.
And then you can see here, our very first request is called login, which sounds pretty promising for
what we're trying to do.
And in here you can see there's a request URL for accounts craigslist.org login.
It's a post method, which is usually what login methods are.
They are post request to a specific endpoint such as login.
And then we can see a response headers.
There's a cookie being set here.
We also have a request header here.
We also have a cookie set already when we make the request.
Then we have the form data which is being passed from our form when we log in.
So here you can see my email and my password that I passed from the form, the previous form.
So if I go log out, I will show you the form.
So here's the form.
With the email and the password.
And this is what is getting passed to this endpoint with a post request in the form data we have here.
Here's the input email handle and here's the password.
And this then gets sent via a post request to this endpoint up here.
Now, this is how a lot of sites lock in work.
They basically make a post request to an endpoint and then a cookie gets set.
And here we can see a session.
Cookie is being set.
It says session session properly for Craigslist session.
And then it has a long string here.
So now when we log in, a cookie gets set on our browser and then Craigslist can see on this cookie
that we are authenticated.
And you can also see a max age on this cookie here.
So this is when the cookie has expired and we need to log in again.
A lot of sites work this way and you just have to dig in the network tab and try and figure out what
kind of data is being sent to this form and how do we then authenticate ourselves.
And now I'm going to show you how we can replicate this inside of Postman so we can try and see how
we can also do this request.