diff --git a/.profile b/.profile new file mode 100644 index 0000000..df779be --- /dev/null +++ b/.profile @@ -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': []} \ No newline at end of file diff --git a/CLI/.profile b/CLI/.profile new file mode 100644 index 0000000..e69de29 diff --git a/CLI/oauth/index.html b/CLI/oauth/index.html index 774e6c5..62f3082 100644 --- a/CLI/oauth/index.html +++ b/CLI/oauth/index.html @@ -14,7 +14,7 @@
- + Sign in with Ion diff --git a/CLI/skoolos.py b/CLI/skoolos.py index 4ebc0cd..57f3ae3 100644 --- a/CLI/skoolos.py +++ b/CLI/skoolos.py @@ -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(): diff --git a/CLI/tester.py b/CLI/tester.py new file mode 100644 index 0000000..c80d4a0 --- /dev/null +++ b/CLI/tester.py @@ -0,0 +1,7 @@ +import requests +import webbrowser + +URL = "chrome://version" +webbrowser.open_new_tab(URL) +r = requests.get(url = URL) +print(r.json()) \ No newline at end of file diff --git a/Website/skoolos/urls.py b/Website/skoolos/urls.py index 9ee53ee..a1e34a3 100644 --- a/Website/skoolos/urls.py +++ b/Website/skoolos/urls.py @@ -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') diff --git a/chromedriver-mac b/chromedriver-mac new file mode 100755 index 0000000..cd12a95 Binary files /dev/null and b/chromedriver-mac differ