Error 401 incorrect user authorization on Modify Channel Information

I fixed the code as you suggested and it worked.
Is there a way to automate this authorization procedure so I dont have to manually generate and enter new code every time I launch the script? I know I can renew the acces_token every ~4 hours, but I am not planning on running the script all day.
I’m also thinking about temporarily hosting my own page at localhost just to automate recieving the code after redirect to it. Any suggestions?