mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
chromium fix
This commit is contained in:
parent
d8aa0c9b11
commit
f91b7a31a7
1
.profile
Normal file
1
.profile
Normal file
|
@ -0,0 +1 @@
|
|||
{'absences': 2, 'address': None, 'counselor': {'first_name': 'Sean', 'full_name': 'Sean Burke', 'id': 37, 'last_name': 'Burke', 'url': 'https://ion.tjhsst.edu/api/profile/37', 'user_type': 'counselor', 'username': 'SPBurke'}, 'display_name': 'Raffu Khondaker', 'emails': [], 'first_name': 'Raffu', 'full_name': 'Raffu Khondaker', 'grade': {'name': 'sophomore', 'number': 10}, 'graduation_year': 2022, 'id': 36508, 'ion_username': '2022rkhondak', 'is_announcements_admin': False, 'is_eighth_admin': False, 'is_student': True, 'is_teacher': False, 'last_name': 'Khondaker', 'middle_name': 'Al', 'nickname': '', 'phones': [], 'picture': 'https://ion.tjhsst.edu/api/profile/36508/picture', 'sex': 'Male', 'short_name': 'Raffu', 'title': None, 'tj_email': '2022rkhondak@tjhsst.edu', 'user_type': 'student', 'websites': []}
|
0
CLI/.profile
Normal file
0
CLI/.profile
Normal file
|
@ -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=5EVwgQRAWaQngvshhCbYiTwC9Rpi7N" 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=81xYFv6S9CLi7laXQ64gJWskDJUMMb" 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>
|
||||
|
|
|
@ -10,6 +10,7 @@ import http.server
|
|||
import socketserver
|
||||
from threading import Thread
|
||||
from werkzeug.urls import url_decode
|
||||
import pprint
|
||||
|
||||
client_id = r'QeZPBSKqdvWFfBv1VYTSv9iFGz5T9pVJtNUjbEr6'
|
||||
client_secret = r'0Wl3hAIGY9SvYOqTOLUiLNYa4OlCgZYdno9ZbcgCT7RGQ8x2f1l2HzZHsQ7ijC74A0mrOhhCVeZugqAmOADHIv5fHxaa7GqFNtQr11HX9ySTw3DscKsphCVi5P71mlGY'
|
||||
|
@ -29,19 +30,29 @@ def main():
|
|||
print("")
|
||||
|
||||
if not os.path.exists(".profile"):
|
||||
print(76546789876545678765)
|
||||
authenticate()
|
||||
print(open(".profile", "r").read())
|
||||
else:
|
||||
print(open(".profile", "r").read())
|
||||
|
||||
while True:
|
||||
pass
|
||||
# while True:
|
||||
# pass
|
||||
|
||||
|
||||
def authenticate():
|
||||
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
|
||||
authorization_url, state = oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/")
|
||||
|
||||
cdir = os.getcwd()
|
||||
#Linux: chromdriver-linux
|
||||
#Macos: chromdriver-mac
|
||||
#Windows: chromdriver.exe
|
||||
path = os.path.join(cdir, "chromedriver-mac")
|
||||
print(path)
|
||||
browser = webdriver.Chrome(path)
|
||||
browser = webdriver.Safari()
|
||||
|
||||
web_dir = os.path.join(os.path.dirname(__file__), 'oauth')
|
||||
os.chdir(web_dir)
|
||||
if os.path.exists("index.html"):
|
||||
|
@ -58,7 +69,6 @@ def authenticate():
|
|||
server.daemon = True
|
||||
server.start()
|
||||
|
||||
browser = webdriver.Chrome()
|
||||
browser.get("localhost:8000/")
|
||||
|
||||
while "http://localhost:8000/?code" not in browser.current_url:
|
||||
|
@ -83,18 +93,20 @@ def authenticate():
|
|||
|
||||
# And finally get the user's profile!
|
||||
profile = requests.get("https://ion.tjhsst.edu/api/profile", headers=headers).json()
|
||||
print(profile)
|
||||
|
||||
pprint.pprint(profile)
|
||||
username = profile['ion_username']
|
||||
email = profile['tj_email']
|
||||
first_name = profile['first_name']
|
||||
last_name = profile['last_name']
|
||||
|
||||
os.chdir("..")
|
||||
os.chdir(cdir)
|
||||
profileFile = open(".profile", "w")
|
||||
profileFile.write(profile.text())
|
||||
#profileFile.write(profile.text())
|
||||
profileFile.write(str(profile))
|
||||
profileFile.close()
|
||||
|
||||
# sys.exit
|
||||
sys.exit
|
||||
|
||||
|
||||
def create_server():
|
||||
|
|
7
CLI/tester.py
Normal file
7
CLI/tester.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
import requests
|
||||
import webbrowser
|
||||
|
||||
URL = "chrome://version"
|
||||
webbrowser.open_new_tab(URL)
|
||||
r = requests.get(url = URL)
|
||||
print(r.json())
|
|
@ -16,7 +16,7 @@ router.register(r'files', api_views.DefFilesViewSet)
|
|||
# Wire up our API using automatic URL routing.
|
||||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', include(router.urls)),
|
||||
path('api/', include(router.urls)),
|
||||
path('api-auth/', include('rest_framework.urls')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('login/', auth_views.LoginView.as_view(template_name="users/login.html"), name='login')
|
||||
|
|
BIN
chromedriver-mac
Executable file
BIN
chromedriver-mac
Executable file
Binary file not shown.
Loading…
Reference in New Issue
Block a user