Open travisbikkle opened 10 months ago
Any reply will be appreciated, please!
I am experiencing the same behavior
import requests
import time
import threading
from flask import Flask
app = Flask(__name__)
stop_thread = threading.Event()
def read_file(path):
with open(path, 'r') as f:
return f.read().strip()
def run_app():
app.run(debug=True, threaded=True, use_reloader=False)
@app.route("/")
def hello_world(req):
print(req)
return "hello go"
def main():
thread = threading.Thread(target=run_app)
thread.start()
time.sleep(1)
params = {
'client_id': read_file('/home/n/.config/ogs/client_id'),
'client_secret': read_file('/home/n/.config/ogs/client_secret'),
'grant_type': 'password',
'username': 'n_sweep',
'password': read_file('/home/n/.config/ogs/pw'),
}
r = requests.post(
"http://online-go.com/oauth2/access_token",
headers={'Content-Type': 'application/x-www-form-urlencoded'},
data=params
)
print(r.status_code, r.text)
if __name__ == '__main__':
main()
λ python run.py
* Serving Flask app 'py'
* Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
* Running on http://127.0.0.1:5000
Press CTRL+C to quit
404
<!doctype html>
<html lang="en">
<head>
<title>Not Found</title>
</head>
<body>
<h1>Not Found</h1><p>The requested resource was not found on this server.</p>
</body>
</html>
curl --include \
--request POST \
--header "Content-Type: application/x-www-form-urlencoded" \
--data-binary "client_id=$(cat ~/.config/ogs/client_id)&client_secret=$(cat ~/.config/ogs/client_secret)&grant_type=password&username=n_sweep&password=$(cat ~/.config/ogs/pw)" \
'http://online-go.com/oauth2/access_token'
HTTP/1.1 301 Moved Permanently
Date: Sun, 22 Sep 2024 17:54:18 GMT
Content-Type: text/html
Content-Length: 167
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Sun, 22 Sep 2024 18:54:18 GMT
Location: https://online-go.com/oauth2/access_token
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v4?s=idk_if_this_is_sensitive"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 8c7428cfe98d2324-ORD
<html>
<head><title>301 Moved Permanently</title></head>
<body>
<center><h1>301 Moved Permanently</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
Describe the bug I followed
create oauth application : https://online-go.com/oauth2/applications/
post to http://online-go.com/oauth2/access_token with client_id, client_secret, grant_type, username, password
I got
What I'm trying to do I'm trying to making a game, user could login in with their ogs account to watch games or play with others. My understanding is, I need to
is that right? or i misunderstood something? cause i've been tyring to figure this out all day and failed, a little frustrating. could anyone help? thanks!