mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-18 19:30:19 -04:00
commit
cada09f96d
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -253,3 +253,4 @@ GitHub.sublime-settings
|
|||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
</head>
|
||||
<body>
|
||||
<div class="d-flex align-items-center justify-content-center" style="height: 100vh">
|
||||
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=QzCUoJEflSWlZe2v7Y3IQEXJFWKIOA" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
||||
<a href="https://ion.tjhsst.edu/oauth/authorize/?response_type=code&client_id=QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6&redirect_uri=http%3A%2F%2Flocalhost%3A8000%2F&scope=read&state=w4hxAszhLTubmyrMqEbaJO6qAM4wCJ" title="Ion" class="border border-dark p-3 btn btn-lg mx-auto" style="box-shadow: 5px 10px;">
|
||||
<img src="https://ion.tjhsst.edu/static/img/favicon.png">
|
||||
Sign in with Ion
|
||||
</a>
|
||||
|
|
|
@ -8,7 +8,7 @@ import os.path
|
|||
import time
|
||||
import http.server
|
||||
import socketserver
|
||||
import threading
|
||||
from threading import Thread
|
||||
from werkzeug.urls import url_decode
|
||||
|
||||
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
|
||||
|
@ -29,6 +29,7 @@ def main():
|
|||
|
||||
if not os.path.exists(".profile"):
|
||||
authenticate()
|
||||
print(open(".profile", "r").read())
|
||||
else:
|
||||
print(open(".profile", "r").read())
|
||||
|
||||
|
@ -45,19 +46,22 @@ def authenticate():
|
|||
if os.path.exists("index.html"):
|
||||
os.remove("index.html")
|
||||
|
||||
template = open("template.html", "rt")
|
||||
index = open("index.html", "wt")
|
||||
template = open("template.html", "r")
|
||||
index = open("index.html", "w")
|
||||
for line in template:
|
||||
index.write(line.replace('AUTH_URL', authorization_url))
|
||||
template.close()
|
||||
index.close()
|
||||
|
||||
threading.Thread(target=create_server).start()
|
||||
# server = Thread(target=create_server)
|
||||
# server.daemon = True
|
||||
# server.start()
|
||||
|
||||
browser = webdriver.Chrome()
|
||||
browser.get("localhost:8000/")
|
||||
|
||||
while "http://localhost:8000/?code" not in browser.current_url:
|
||||
http.server.
|
||||
time.sleep(0.25)
|
||||
|
||||
url = browser.current_url
|
||||
|
@ -75,16 +79,22 @@ def authenticate():
|
|||
'client_secret': client_secret, 'csrfmiddlewaretoken': state}
|
||||
token = requests.post("https://ion.tjhsst.edu/oauth/token/", data=payload).json()
|
||||
print(token)
|
||||
# headers = {'Authorization': f"Bearer {token['access_token']}"}
|
||||
#
|
||||
# # And finally get the user's profile!
|
||||
# profile = requests.get("https://ion.tjhsst.edu/api/profile", headers=headers).json()
|
||||
# username = profile['ion_username']
|
||||
# email = profile['tj_email']
|
||||
# first_name = profile['first_name']
|
||||
# last_name = profile['last_name']
|
||||
headers = {'Authorization': f"Bearer {token['access_token']}"}
|
||||
|
||||
# And finally get the user's profile!
|
||||
profile = requests.get("https://ion.tjhsst.edu/api/profile", headers=headers).json()
|
||||
print(profile)
|
||||
username = profile['ion_username']
|
||||
email = profile['tj_email']
|
||||
first_name = profile['first_name']
|
||||
last_name = profile['last_name']
|
||||
|
||||
profileFile = open(".profile", "w")
|
||||
profileFile.write(profile)
|
||||
profileFile.close()
|
||||
|
||||
# server.stop
|
||||
|
||||
# print(profile)
|
||||
|
||||
def create_server():
|
||||
port = 8000
|
||||
|
|
Loading…
Reference in New Issue
Block a user