diff --git a/src/unlearn/__pycache__/learn_config.cpython-310.pyc b/src/unlearn/__pycache__/learn_config.cpython-310.pyc index ca109eeec207a8ddacb2aa25dfc53294983e0f35..6bf58b8ff7c07b706d21fa570045e0b6528c746b 100644 Binary files a/src/unlearn/__pycache__/learn_config.cpython-310.pyc and b/src/unlearn/__pycache__/learn_config.cpython-310.pyc differ diff --git a/src/unlearn/api.py b/src/unlearn/api.py new file mode 100644 index 0000000000000000000000000000000000000000..100b71685f840c5d0644eeeba735430348fe6a7e --- /dev/null +++ b/src/unlearn/api.py @@ -0,0 +1,5 @@ +import uvicorn + + +if __name__ == "__main__": + uvicorn.run(app, host="0.0.0.0", port=8000) diff --git a/src/unlearn/cache/cache.db b/src/unlearn/cache/cache.db index fd897644e84229987f58d420bff790a339e69599..5a465383480a955a4d7182746db396d09b70aaf9 100644 Binary files a/src/unlearn/cache/cache.db and b/src/unlearn/cache/cache.db differ diff --git a/src/unlearn/chromedriver b/src/unlearn/chromedriver new file mode 100755 index 0000000000000000000000000000000000000000..f0e0dd16802d655372059db019ae945c008d41a4 Binary files /dev/null and b/src/unlearn/chromedriver differ diff --git a/src/unlearn/flowlogin.py b/src/unlearn/flowlogin.py new file mode 100644 index 0000000000000000000000000000000000000000..ab4c9d50f31cbebe3dc1a0cd10a1ab68261d5f8d --- /dev/null +++ b/src/unlearn/flowlogin.py @@ -0,0 +1,61 @@ +from rauth import OAuth2Service +import json + +class ExampleOAuth2Client: + def __init__(self, client_id, client_secret, url="https://auth.brightspace.com/core/connect/token"): + self.access_token = None + + self.service = OAuth2Service( + name="testdtuToken", + client_id=client_id, + client_secret=client_secret, + access_token_url="https://auth.brightspace.com/core/connect/token", + authorize_url="https://auth.brightspace.com/oauth2/auth", # "http://api.example.com/oauth/access_token", + base_url="http://auth.brightspace.com/", + + ) + + redirect_uri = 'https://localhost:3434/redirecturi' + params = {'scope': 'core:*:*', + 'response_type': 'code', + 'redirect_uri': redirect_uri, + 'state': 'good'} + + url = self.service.get_authorize_url(**params) + print(url) + + session = self.service.get_auth_session(data={'redirect_uri': redirect_uri, 'grant_type': 'authorization_code', 'code': 'good'}, decoder=json.loads) + + self.get_access_token() + + def get_access_token(self): + data = {'code': 'bar', # specific to my app + 'grant_type': 'client_credentials', # generally required! + } + + session = self.service.get_auth_session(data=data, decoder=json.loads) + + self.access_token = session.access_token + +if __name__ == "__main__": + from unlearn.learn_config import LearnConfig, start_localhost + url = "https://auth.brightspace.com/core/connect/token" + # refresh_token = cc['refresh_token'] + # refresh_token = "rt.eu-west-1.SAmtMKD3oe094NV6Yc4F8UuROyRdHMJRz_XwpiYtwfI" + client_id = "4801a477-11c7-4cfc-8732-736f041578be" + client_secret = "niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8" + # payload = f'grant_type=refresh_token&refresh_token={refresh_token}&client_id={self.client_id}&client_secret={self.client_secret}&scope=core%3A*%3A*' + # headers = { + # 'Content-Type': 'application/x-www-form-urlencoded' + # } + + # response = requests.request("POST", url, headers=headers, data=payload) + + # lc = LearnConfig() + start_localhost() + + ec = ExampleOAuth2Client(client_id, client_secret) + a = 234 + + + pass \ No newline at end of file diff --git a/src/unlearn/flowlogin2.py b/src/unlearn/flowlogin2.py new file mode 100644 index 0000000000000000000000000000000000000000..64cf01cdd33701ee13411a5c2a5204a6c3e81d86 --- /dev/null +++ b/src/unlearn/flowlogin2.py @@ -0,0 +1,126 @@ +# file: flow_managers.py + + + +from rauth import OAuth2Service +import json + +class ExampleOAuth2Client: + def __init__(self, client_id, client_secret, url="https://auth.brightspace.com/core/connect/token"): + self.access_token = None + + self.service = OAuth2Service( + name="testdtuToken", + client_id=client_id, + client_secret=client_secret, + access_token_url="https://auth.brightspace.com/core/connect/token", + authorize_url="https://auth.brightspace.com/oauth2/auth", # "http://api.example.com/oauth/access_token", + base_url="http://auth.brightspace.com/", + + ) + + redirect_uri = 'https://localhost:3434/redirecturi' + params = {'scope': 'core:*:*', + 'response_type': 'code', + 'redirect_uri': redirect_uri, + 'state': 'good'} + + url = self.service.get_authorize_url(**params) + print(url) + + session = self.service.get_auth_session(data={'redirect_uri': redirect_uri, 'grant_type': 'authorization_code', 'code': 'good'}, decoder=json.loads) + + self.get_access_token() + + def get_access_token(self): + data = {'code': 'bar', # specific to my app + 'grant_type': 'client_credentials', # generally required! + } + + session = self.service.get_auth_session(data=data, decoder=json.loads) + + self.access_token = session.access_token + +# from fastapi import FastAPI +# from fastapi.responses import HTMLResponse + +# from .flow_managers import se_flow_manager + +# app = FastAPI() +# +# @app.get('/stuff') +# def get_providers(): +# state = "42" +# se_auth_url = se_flow_manager.get_authorization_endpoint(state) +# html_content = f""" +# <html> +# <head> +# <title>Connect your account</title> +# </head> +# <body> +# <p>Please select any of the links below to connect your account to the provider</p> +# <p><a href="{se_auth_url}" target="_blank">Connect to Stack Exchange</a></p> +# </body> +# </html> +# """ +# return HTMLResponse(html_content) + +if __name__ == "__main__": + from unlearn.learn_config import LearnConfig, start_localhost, S + url = "https://auth.brightspace.com/core/connect/token" + # refresh_token = cc['refresh_token'] + # refresh_token = "rt.eu-west-1.SAmtMKD3oe094NV6Yc4F8UuROyRdHMJRz_XwpiYtwfI" + client_id = "4801a477-11c7-4cfc-8732-736f041578be" + client_secret = "niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8" + # payload = f'grant_type=refresh_token&refresh_token={refresh_token}&client_id={self.client_id}&client_secret={self.client_secret}&scope=core%3A*%3A*' + # headers = { + # 'Content-Type': 'application/x-www-form-urlencoded' + # } + + # response = requests.request("POST", url, headers=headers, data=payload) + + # lc = LearnConfig() + access_token_url = "https://auth.brightspace.com/core/connect/token" + authorize_url = "https://auth.brightspace.com/oauth2/auth" # "http://api.example.com/oauth/access_token", + base_url = "https://auth.brightspace.com" + redirect_uri = 'https://localhost:3434/redirecturi' + from auth_code_flow import FlowManager + """ + https://auth.brightspace.com/oauth2/auth?response_type=code&client_id=4801a477-11c7-4cfc-8732-736f041578be&scope=core%3A*%3A*&redirect_uri=https%3A%2F%2Flocalhost%3A3434%2Fredirecturi + http://auth.brightspace.com/oauth2/auth?client_id=4801a477-11c7-4cfc-8732-736f041578be&redirect_uri=https%3A%2F%2Flocalhost%3A3434%2Fredirecturi&response_type=code&scope=core%3A%2A%3A%2A&state=my_state + + """ + se_flow_manager = FlowManager( + base_uri=base_url, + client_id=client_id, + client_secret=client_secret, # "your client secret", # please read this from env vars for security + redirect_uri=redirect_uri, + scope="core:*:*", + access_token_path="/core/connect/token", + authorization_path="/oauth2/auth", + response_type='code', + ) + start_localhost(se_flow_manager) + + state = "my_state" + se_auth_url = se_flow_manager.get_authorization_endpoint(state) + print(se_auth_url) + + + + print("Code obtained from server", S.CODE) + # lc = LearnConfig(refresh_token=S.CODE) + + code = S.CODE + resp = se_flow_manager.fetch_access_token(code, state, post_form_data=True) + resp_json = resp.json() + access_token = resp_json['access_token'] + refresh_token = resp_json['refresh_token'] + + lc = LearnConfig() + + ec = ExampleOAuth2Client(client_id, client_secret) + a = 234 + + + pass \ No newline at end of file diff --git a/src/unlearn/geckodriver.log b/src/unlearn/geckodriver.log new file mode 100644 index 0000000000000000000000000000000000000000..71099cf92180c2b81e688aecd633b84b06fb09a4 --- /dev/null +++ b/src/unlearn/geckodriver.log @@ -0,0 +1,18 @@ +1665440787180 geckodriver INFO Listening on 127.0.0.1:60967 +1665440787706 mozrunner::runner INFO Running command: "/usr/bin/firefox" "--marionette" "--remote-debugging-port" "39301" "--remote-allow-hosts" "localhost" "-no-remote" "-profile" "/tmp/rust_mozprofilek9MuTe" +ATTENTION: default value of option mesa_glthread overridden by environment. +ATTENTION: default value of option mesa_glthread overridden by environment. +ATTENTION: default value of option mesa_glthread overridden by environment. +ATTENTION: default value of option mesa_glthread overridden by environment. +1665440789077 Marionette INFO Marionette enabled +1665440789084 Marionette INFO Listening on port 43913 +Read port: 43913 +WebDriver BiDi listening on ws://127.0.0.1:39301 +1665440789252 RemoteAgent WARN TLS certificate errors will be ignored for this session +console.warn: SearchSettings: "get: No settings file exists, new profile?" (new NotFoundError("Could not open the file at /tmp/rust_mozprofilek9MuTe/search.json.mozlz4", (void 0))) +Missing chrome or resource URL: resource://gre/modules/UpdateListener.sys.mjs +DevTools listening on ws://127.0.0.1:39301/devtools/browser/16d42f47-0161-4667-b0c7-f9b7f7ee9a13 +Missing chrome or resource URL: resource://gre/modules/UpdateListener.sys.mjs +console.error: "Error during quit-application-granted: [Exception... \"File error: Not found\" nsresult: \"0x80520012 (NS_ERROR_FILE_NOT_FOUND)\" location: \"JS frame :: resource:///modules/BrowserGlue.jsm :: _onQuitApplicationGranted/tasks< :: line 2009\" data: no]" +1665441520882 Marionette INFO Stopped listening on port 43913 +console.warn: TopSitesFeed: Failed to fetch data from Contile server: NetworkError when attempting to fetch resource. diff --git a/src/unlearn/learn_config.py b/src/unlearn/learn_config.py index 89b0aa5e929ff504a9bc31d978cd2aea82199bfb..72f58b8784e2cb2d5a69d59d589a032b7335f537 100644 --- a/src/unlearn/learn_config.py +++ b/src/unlearn/learn_config.py @@ -1,13 +1,13 @@ -import pickle -import diskcache -import requests -from diskcache import Cache +from urllib.parse import urlparse +import json import os +from http.server import BaseHTTPRequestHandler +from threading import Thread +from auth_code_flow import FlowManager +from diskcache import Cache +from selenium import webdriver +from selenium.webdriver.common.by import By -""" -Links -API: -""" def whoami(lc): url = "https://testdtu.brightspace.com/d2l/api/lp/1.36/users/whoami" @@ -52,10 +52,89 @@ class LearnConfig: print(json) return False - def __init__(self): + def _oauth2_refresh(self, username='tuhe', password=None): + url = "https://auth.brightspace.com/core/connect/token" + client_id = "4801a477-11c7-4cfc-8732-736f041578be" + client_secret = "niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8" + + # access_token_url = "https://auth.brightspace.com/core/connect/token" + # authorize_url = "https://auth.brightspace.com/oauth2/auth" # "http://api.example.com/oauth/access_token", + base_url = "https://auth.brightspace.com" + redirect_uri = 'https://localhost:3434/redirecturi' + """ + https://auth.brightspace.com/oauth2/auth?response_type=code&client_id=4801a477-11c7-4cfc-8732-736f041578be&scope=core%3A*%3A*&redirect_uri=https%3A%2F%2Flocalhost%3A3434%2Fredirecturi + http://auth.brightspace.com/oauth2/auth?client_id=4801a477-11c7-4cfc-8732-736f041578be&redirect_uri=https%3A%2F%2Flocalhost%3A3434%2Fredirecturi&response_type=code&scope=core%3A%2A%3A%2A&state=my_state + """ + se_flow_manager = FlowManager( + base_uri=base_url, + client_id=client_id, + client_secret=client_secret, # "your client secret", # please read this from env vars for security + redirect_uri=redirect_uri, + scope="core:*:*", + access_token_path="/core/connect/token", + authorization_path="/oauth2/auth", + response_type='code', + ) + ll = start_localhost(se_flow_manager) + + state = "my_state" + se_auth_url = se_flow_manager.get_authorization_endpoint(state) + print(se_auth_url) + + driver = webdriver.Firefox() + + # with requests.session() as s: + # OAuth_AccessRequest = s.get(se_auth_url) + + driver.get(se_auth_url) + # username = driver.find_element(by="id",value="userName") + # password = driver.find_element(by="id", value="password") + # button = driver.find_element(by="type", value="button") + usernane = driver.find_element(By.ID, "userName") + # username + usernane.send_keys(username) + if password is None: + password = input(f'Please provide password for {username=}') + + fpassword = driver.find_element(By.ID, "password") + fpassword.send_keys(password) + + # submit = driver.find_element(By.ID, "formId") + # submit.submit() + + button = driver.find_element(By.TAG_NAME, "button") + button.click() + print("> Code obtained from server", S.CODE) + # lc = LearnConfig(refresh_token=S.CODE) + code = S.CODE + ll.shutdown() + print("Code obtained is", code) + resp = se_flow_manager.fetch_access_token(code, state, post_form_data=True) + resp_json = resp.json() + access_token = resp_json['access_token'] + refresh_token = resp_json['refresh_token'] + print("Obtained tokens through login: ") + print(f"> {access_token=}") + print(f"> {refresh_token=}") + self.cc['access_token'] = access_token + self.cc['refresh_token'] = refresh_token + print("Checking if valid...") + # Check if valid: + self.is_token_valid() + print("All done!") + + + def __init__(self, refresh_token=None): cc = Cache(directory= os.path.join( os.path.dirname(__file__), "cache") ) + # if "refresh_token" in cc: + # del cc['refresh_token'] + # if "access_token" in cc: + # del cc['access_token'] + self.cc = cc + # if refresh_token is not None: + # cc['refresh_token'] = refresh_token while True: if "access_token" in cc: print("is there") @@ -75,48 +154,310 @@ class LearnConfig: if "refresh_token" in cc: url = "https://auth.brightspace.com/core/connect/token" + print("Getting refresh token using", refresh_token) refresh_token = cc['refresh_token'] # refresh_token = "rt.eu-west-1.SAmtMKD3oe094NV6Yc4F8UuROyRdHMJRz_XwpiYtwfI" + self.client_id = "4801a477-11c7-4cfc-8732-736f041578be" self.client_secret = "niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8" - payload=f'grant_type=refresh_token&refresh_token={refresh_token}&client_id={self.client_id}&client_secret={self.client_secret}&scope=core%3A*%3A*' - headers = { - 'Content-Type': 'application/x-www-form-urlencoded' - } + payload=f'grant_type=refresh_token&refresh_token={refresh_token}&client_id={self.client_id}&client_secret={self.client_secret}&scope=core%3A*%3A*' + headers = {'Content-Type': 'application/x-www-form-urlencoded' } response = requests.request("POST", url, headers=headers, data=payload) + print(response.json()) cc['refresh_token'] = response.json()['refresh_token'] cc['access_token'] = response.json()['access_token'] print("Authentication success.") break - - # url = "https://auth.brightspace.com/core/connect/token" - # - # payload = 'grant_type=refresh_token&refresh_token=rt.eu-west-1.QLXytJ-TREfofv9xzbDcBEiEivw-_rogaSmS8XetScg&client_id=4801a477-11c7-4cfc-8732-736f041578be&client_secret=niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8&scope=core%3A*%3A*' - # headers = { - # 'Content-Type': 'application/x-www-form-urlencoded' - # } - # - # response = requests.request("POST", url, headers=headers, data=payload) - # - # print(response.text) - # - # - # print(response.text) - else: - s = input("Please give me a refresh token") - cc['refresh_token'] = s - print("Saved refresh token", s) + # Do oauth2 refreshing... + self._oauth2_refresh() + # s = input("Please give me a refresh token") + # cc['refresh_token'] = s + # print("Saved refresh token", s) print("no it is not there") - a = 234 print("Phew! Authentication completed.") - # load refresh token file. - # test if login possible with current token. - # pkl.get - # rt.eu-west-1.tN5byZD8n0KHSowkDC2NnElZx0J0BJgIz57Fmj-ZhKs - pass + + +class S(BaseHTTPRequestHandler): + def _set_headers(self): + self.send_response(200) + self.send_header("Content-type", "text/html") + self.end_headers() + + def _html(self, message): + """This just generates an HTML document that includes `message` + in the body. Override, or re-write this do do more interesting stuff. + """ + content = f"<html><body><h1>{message}</h1></body></html>" + return content.encode("utf8") # NOTE: must return a bytes object! + + def do_GET(self): + self._set_headers() + query = urlparse(self.path) + code = query.query.split('=')[1].split('&')[0] + S.CODE = code + self.wfile.write(self._html(f"url: {url}<br>Code was: {code}")) + + def do_HEAD(self): + self._set_headers() + + def do_POST(self): + # Doesn't do anything with posted data + self._set_headers() + self.wfile.write(self._html("POST!")) + + # def do_QUIT (self): + # """send 200 OK response, and set server.stop to True""" + # self.send_response(200) + # self.end_headers() + # self.server.stop = True + +class LocalListen(Thread): + def shutdown(self): + print("> localhost: stopping https server...") + self.httpd.shutdown() + print("> localhost: stopped.") + + def run(self): + # while True: + print("hello world") + import http.server + # import ht + import socketserver + import ssl + PORT = 3434 + # Handler = http.server.SimpleHTTPRequestHandler + with socketserver.TCPServer(("localhost", PORT), S) as httpd: + httpd.socket = ssl.wrap_socket(httpd.socket, certfile=os.path.join(os.path.dirname(__file__), 'server.pem'), server_side=True) + # httpd.serve_forever() + print("> localhost: serving at port", PORT) + print(httpd.server_address) + self.httpd = httpd + httpd.serve_forever() + print("> localhost: Stopping...") + + + + + +# import SimpleHTTPServer, BaseHTTPServer, httplib + +# import socketserver +# class StoppableRPCServer(socketserver.TCPServer): +# stopped = False +# allow_reuse_address = True +# +# def __init__(self, *args, **kw): +# super().__init__(self, *args, **kw) +# self.register_function(lambda: 'OK', 'ping') +# +# def serve_forever(self): +# while not self.stopped: +# self.handle_request() +# +# def force_stop(self): +# self.server_close() +# self.stopped = True +# self.create_dummy_request() +# +# def create_dummy_request(self): +# server = xmlrpclib.Server('http://%s:%s' % self.server_address) +# server.ping() + + +# def stop_server (port): +# """send QUIT request to http server running on localhost:<port>""" +# conn = httplib.HTTPConnection("localhost:%d" % port) +# conn.request("QUIT", "/") +# conn.getresponse() + + +def start_localhost(flow_manager=None): + S.flow_manager = flow_manager + ll = LocalListen() + ll.start() + return ll + if __name__ == '__main__': print("Hello world") + lc = LearnConfig() + + # file: flow_managers.py + ll = LocalListen() + ll.start() + + + ll.httpd.shutdown() + + a = 234 + # se_flow_manager = FlowManager( + # base_uri="https://stackoverflow.com", + # client_id="20146", + # client_secret="your client secret", # please read this from env vars for security + # redirect_uri="http://localhost:8000/oauth/callback/stackexchange", + # scope="no_expiry", + # access_token_path="/oauth/access_token/json", + # authorization_path="/oauth", + # ) + + import requests + import urllib.parse + from bs4 import BeautifulSoup + + user = 'tuhe' + + psw = '...' + + params = {'client_id': "4801a477-11c7-4cfc-8732-736f041578be", + 'redirect_uri': "https://localhost:3434/redirecturi", + 'response_type': "code", + 'force_login': "1", + 'scope': 'core:*:*', + 'client_secret': 'niLXYwe9f_pQe2RzvZ8LtYE6Ls6DSiZ_0IeTCPhx4_8'} + + url = 'https://auth.brightspace.com/oauth2/auth' + token_url = 'https://auth.brightspace.com/core/connect/token' + + + + driver = webdriver.Firefox() + + with requests.session() as s: + OAuth_AccessRequest = s.get(url, params=params) + + driver.get(OAuth_AccessRequest.url) + # username = driver.find_element(by="id",value="userName") + # password = driver.find_element(by="id", value="password") + # button = driver.find_element(by="type", value="button") + usernane = driver.find_element(By.ID, "userName") + usernane.send_keys("tuhe") + + password = driver.find_element(By.ID, "password") + password.send_keys("..") + + # submit = driver.find_element(By.ID, "formId") + # submit.submit() + + button = driver.find_element(By.TAG_NAME, "button") + button.click() + + print("Clicked, seeeing what happens next.") + + button = driver.find_element(by="type", value="button") + + + + + # user = driver.find_element_by_id("userName") + + + ss = OAuth_AccessRequest.content.decode("utf8") + ss = ss.split("script")[1] + ss = ss[ss.find("replace(")+9:].split(" ")[0][:-1] + surl = url + ss + surl = 'https://testdtu.brightspace.com' + ss + print(surl) + with requests.session() as s: + r = s.get(surl ) + + dd = r.content.decode("utf8") + with open("index.html", 'w') as f: + f.write(dd) + + soup = BeautifulSoup(r.content) + inputs = soup.find_all("input") + x = [{'name': i.attrs['name'], 'value': i.attrs.get('value', None)} for i in inputs] + args = {} + for kv in x: + args[kv['name']] = kv['value'] + args['userName'] = "..." + args['password'] = "..." + headers = {'Content-Type': 'application/json'} + payload = json.dumps(args) + + with requests.session() as s: + r = s.post(surl, headers=headers, data=payload) + + print(inputs) + + + soup.form + form = soup.form + login_data = {e['name']: e.get('value', '') for e in form.find_all('input', {'name': True})} + login_data.update({'UserNameField': user, 'PasswordField': psw}) + login_data.update({'hf2StepLoginStep': 1}) + # login_url = OAuthURL.format(form.attrs['action']) + + # with requests.session() as s: + # Actual_login = s.get(login_url, params=login_data) + # + # Authorization_code = Actual_login.url.split("https://salesanalysisexact.herokuapp.com/?code=")[-1] + # Authorization_code = urllib.parse.unquote(Authorization_code) + # print(Authorization_code) + + # import selenium + from selenium import webdriver + # webdriver.Chrome() + # driver = webdriver.Firefox() + # from selenium.webdriver.chrome.options import Options + from selenium.webdriver.chrome.options import Options + from selenium import webdriver + from webdriver_manager.chrome import ChromeDriverManager + # from webdriver_manager.firefox import GeckoDriverManager + from webdriver_manager.firefox import GeckoDriverManager + + # driver = webdriver.Firefox(GeckoDriverManager().install()) + opts = GeckoDriverManager() + # options = webdriver.FirefoxOptions() + # options.binary = binary + driver = webdriver.Firefox() # executable_path="/home/tuhe/.wdm/drivers/geckodriver/linux64/0.31/geckodriver") + # browser.get("http:/google.com") + # driver = webdriver.Firefox() + driver.get("http://www.python.org") + import asyncio + from pyppeteer import launch + + async def main(): + browser = await launch() + page = await browser.newPage() + await page.goto('https://example.com') + await page.screenshot({'path': 'example.png'}) + await browser.close() + + + asyncio.get_event_loop().run_until_complete(main()) + + + driver = webdriver.Chrome(ChromeDriverManager().install()) + + # driver = webdriver.Firefox() + driver.get("http://www.python.org") + + OAuthURL = OAuth_AccessRequest.url + s = driver.get(OAuthURL) + + opts = Options() + opts.chromedriver_path = os.path.join(os.path.dirname(__file__), "chromium.chromedriver") + opts.chromedriver_path = "/snap/bin/chromium.chromedriver" + + opts.binary_location = "/snap/bin/chromium" + import sys + sys.path.append(os.path.dirname(__file__)) + + assert os.path.isfile(opts.chromedriver_path) + driver = webdriver.Chrome(chrome_options=opts) + opts = Options() + + + # driver = webdriver.Chrome(chrome_options=opts) + + + + + + + + c = LearnConfig() diff --git a/src/unlearn/main.py b/src/unlearn/main.py index 950cb8ba0cee7b7fd367bdfc281cece193caf3f8..1cafcf966edb16db40c8f41c2b5739d072320223 100644 --- a/src/unlearn/main.py +++ b/src/unlearn/main.py @@ -15,7 +15,7 @@ def get_calendar_events(lc): response = requests.request("GET", url, headers=lc.headers, data=payload) print(response.text) return response - pass + def put_calendar_event(lc, start_date, end_date, title="Lecture", description="Do some stuff today", location_name="Auditorim 666"): """ diff --git a/src/unlearn/server.pem b/src/unlearn/server.pem new file mode 100644 index 0000000000000000000000000000000000000000..02674626f18eb766d4efc87d3e835dac49c1f6ac --- /dev/null +++ b/src/unlearn/server.pem @@ -0,0 +1,49 @@ +-----BEGIN PRIVATE KEY----- +MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCF9n7OS6358dp1 +667LPKcP7ocSWpbaVYslUseTU5fqD5tcuZM8Rvcp9IItVhkK/kwoLJG8phql/8Pe +82ZvmzqftqRIkmzv4rUSK/SatFSvYTQy9kYqeZ3md3zwJsqa1PyAg2gIg/l8LK8o +mhgYU7hQ6gfpN1eXEV97jG2JKHDah+oq9dHPBlbKBR7ULCK9BWniLYKDid1+n+nO +Q40EOuUnwqGJGldqH0bHW9ZPDwi00VdXmv3OcpZj0VN3rbL7LNfTOWSX1TxMcUO3 +vqra+x++N05w9zGoe+zQr2gmvhEw1zAkWaCs2VOYsgTEkrHzXt0o3yuZtk2QTaTg +4JYJBl+TAgMBAAECgf9wag7pcCMiwDr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