Skip to content

authorization doesn't work on Amazon Linux #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ibuergis opened this issue Oct 5, 2023 · 7 comments
Open

authorization doesn't work on Amazon Linux #72

ibuergis opened this issue Oct 5, 2023 · 7 comments

Comments

@ibuergis
Copy link

ibuergis commented Oct 5, 2023

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
(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

@Stedoss
Copy link
Contributor

Stedoss commented Oct 5, 2023

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.

@ibuergis
Copy link
Author

ibuergis commented Oct 5, 2023

image
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

@tybug
Copy link
Owner

tybug commented Oct 8, 2023

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.

@tybug
Copy link
Owner

tybug commented Oct 17, 2023

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.

@tybug tybug closed this as completed Oct 17, 2023
@ibuergis
Copy link
Author

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".

@tybug
Copy link
Owner

tybug commented Oct 26, 2023

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.

@ibuergis
Copy link
Author

it doesnt hurt to try...

@tybug tybug reopened this Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants