ossapi
ossapi copied to clipboard
authorization doesn't work on Amazon Linux
I am currently trying to host my bot on an aws server and when the osu website is trying to send the data to localhost. It is telling me that the connection is getting refused. I made sure that both osu and my program have the same localhost ports.
I did look a bit into it and it should be possible to create a webserver on localhost so I dont understand why it doesnt work.
(censorship on point)
to view the website I am using elinks.
For python I am using 3.10
I installed these packages into my instance via yum: xz-devel lzma zlib-devel gcc openssl-devel bzip2-devel libffi-devel make elinks
and I installed these libraries into my python: discord pycord ossapi pillow sqlalchemy pymysql
That request suggests that you are trying to use port 80 for the callback, which most likely won't work due to how linux port binding works (ossapi spins up its own server to accept the token callback). Try a port above 1024, which should be linux user bindable.
I now tried it with the example port and several other ports but I still get the same result. I also made sure to update the information in the code and on osu accordingly
I'm not entirely sure how remoting into an aws server works or how you are accessing the webpage , so it's hard for me to offer specific advice. But maybe it will help you debug if I describe the flow ossapi goes through:
-
ossapi = Ossapi(client_id, client_secret, redirect_url)
is called - ossapi opens an oauth page on osu.ppy.sh using
webbrowser.open
.- I don't know what this defaults to on aws or linux.
- ossapi opens a socket on the localhost port specified in
redirect_url
. - when you click "authenticate" in your browser on the oauth page opened in step 2, you are redirected to the port on localhost, where ossapi receives your credentials in the http GET headers of that request.
This process could be failing at a few places here. It may be up to you to determine which step, or provide more info.
I'm going to close this for now, but feel free to comment with more information and I'll try to help as best I can! Who knows - we might have a real bug here, or something ossapi can do better.
So I looked into it again and Ive tried two things:
I created a new instance with windows using the same security rules. I started a webserver myself on the port to see if I can even open and access the webserver using the port.
First the windows one surprisingly works fine which is good and does proof that my aws settings should support opening ports.
The webserver that I started also worked fine and I had full access on it.
It does seem like that the way ossapi opens the socket isnt compatible with amazon linux for some reason.
I ran the webserver with this command: "python3 -m http.server 3914 --directory ~/folder".
Thanks for the update.
I wonder if changing ossapi to use serversocket.bind(("127.0.0.1", port))
instead of serversocket.bind(("localhost", port))
would make a difference here.
it doesnt hurt to try...