HTTP to log into Website

I am new to n8n and I am learning a lot. I used chatgpt to try to help me out with this workflow but I can’t see to figure it out on my own. I searched the community site and the discord server but I still can’t find an example to help me.

So here is what I am working on. I get emails from this website that say when the weekly events are happening. There are usually a few different events throughout the week. The website is kajabi site but uses a custom domain (https://academy.learnyourcnc.com/login). So based on what I have learned, I need to create couple of HTTP request nodes to log me into the site and get a token. This is where I am struggling. I have tried many different configurations on the HTTP node to try log me in. I tried GET and POST requests. With the GET I seem to get the HTTP code for the login page but it won’t send the basic authentication I set up. I tried a few other configs as suggested by my search and ChatGPT. Nothing has worked. I am hoping someone here can show me how I would accomplish this. I want to be able to log in and get the event date and time and zoom links.

I know I can do this manually, but I figured if I can automate this, it would save me a lot of time and missed events because I didn’t see the email or get around to adding it to my calendar in time.

Information on your n8n setup

  • n8n version: 1.42.1
  • Database (default: SQLite): default
  • **n8n EXECUTIONS_PROCESS setting (default: own, main):**own
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker on Zimaboard
  • Operating system: CasaOS

Hi @jlhsolutions ,

Welcome to the community! :dizzy:

So, this is a tricky one as it varies a lot with different websites.
For this one in particular it looks like you need to make a POST request to this url https://academy.learnyourcnc.com/login and pass this data:

authenticity_token
member[email]
member[password]

You’d pass these as body params in your node.

You could also try to automate this by having an HTTP GET request fetching you the HTML, extract a token from it and use that in a body POST.

However, without knowing how the website sets their tokens, it is very hard to be able to pass it - most commonly nowadays tokens change with every request. You might be better off reaching out and asking them if they could share their API. Otherwise you could consider something like Puppeteer or browserless.

And since you mentioned you were using chatgpt, this might interest you too: https://www.phind.com/search?home=true it’s an AI engine focused on helping developers with technical problems. Sometimes it’s a bit more insightfull than gpt - worth a try :space_invader:

@mariana-na I tried what you showed and it gives me a 422 error. I did reach out and the person I asked wasn’t familiar with how to do this. All they did was sign up for the kajabi service to host their stuff. He wasn’t sure why I wanted to automate this when I could just login and manually add the events to my calendar. I checked out those other services you recommended. So far I haven’t been able to figure anything out.

When I use the GET function, I get the source code returned for the log in page. But then I can’t seem to figure out how to go from there. I’m brand new to this stuff and don’t know a lot, but I am trying to google what I can figure this out as I think this type of stuff is so cool and going to be huge in the future.

If you have any other ideas, please let me know! I am willing to learn as much as I can.

@mariana-na After trying Phind, it suggested I use Postman. I then tried accessing the site there. After creating a GET call, I got the CSRF token. I then used that in the POST call with my username and password. I was able to get logged into the site.

So using those details in my HTTP nodes, I still can’t get in. I am getting a 422 error. Here are a couple of screenshots from Postman and my Nodes. Maybe you can see something I did wrong.

Postman GET

Postman POST
Header


Body

n8n POST node


So I made some progress in figuring this out, but now I can’t figure out why n8n doesn’t work when I used the exact same info in Postman and it let me log in.

I still haven’t been able to figure this out. Postman seems to get and store the cookie, but I can’t figure out how to get the cookie in n8n. I keep getting a 422 error. I have googled this but I am not coming up with anything. Does anyone have any ideas on how to make this work?

Areyou running n8n on localhost:5678, if so, try checking the CORS.Might be the limiting factor

I bought a domain name and have that pointed to the device. I googled CORS as I have never heard of this before and I came up with this Cross-Origin Resource Sharing (CORS). So then I tried searching the community for this but everything posted was quite old. But I couldn’t find anything on how to see or enable/disable this if this is the problem. Could you provide some insight on this?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.