From bdfed579424cc258205b1b695e43b95b73e39f40 Mon Sep 17 00:00:00 2001 From: BuildTools Date: Tue, 27 Oct 2020 18:21:45 +0100 Subject: [PATCH] Script to get token - checkpoint --- .gitignore | 5 +++++ pom.xml | 33 +++++++++++++++++++++++++++------ token.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 6 deletions(-) create mode 100755 token.py diff --git a/.gitignore b/.gitignore index a2a3040..41c11c4 100755 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,8 @@ build/ ### VS Code ### .vscode/ + + +### Python ### +__pycache__ +.pytest_cache \ No newline at end of file diff --git a/pom.xml b/pom.xml index 790c301..08f48fe 100755 --- a/pom.xml +++ b/pom.xml @@ -2,11 +2,11 @@ 4.0.0 - org.springframework.boot - spring-boot-starter-parent - 2.2.2.RELEASE - - + org.springframework.boot + spring-boot-starter-parent + 2.2.2.RELEASE + + com.plannaplan backend @@ -75,10 +75,31 @@ maven-project-info-reports-plugin 3.0.0 + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + generateSources + generate-sources + + + + + + + + + run + + + + - + buisnesslogic restservice diff --git a/token.py b/token.py new file mode 100755 index 0000000..45889d7 --- /dev/null +++ b/token.py @@ -0,0 +1,35 @@ +import webbrowser +from http.server import BaseHTTPRequestHandler, HTTPServer, SimpleHTTPRequestHandler +import urllib.parse as urlparse +from urllib.parse import parse_qs +import pyperclip +import sys +# replace with your own http handlers + + +class S(BaseHTTPRequestHandler): + def _set_response(self): + self.send_response(200) + self.send_header('Content-type', 'text/html') + self.end_headers() + + def do_GET(self): + parsed = urlparse.urlparse(str(self.path)) + ticket = str(parse_qs(parsed.query)['ticket'][0]) + print(ticket) + pyperclip.copy(ticket) + self._set_response() + self.wfile.write("Token copied to clipboard".format().encode('utf-8')) + + +def wait_for_request(server_class=HTTPServer, + handler_class=S): + server_address = ('localhost', 3000) + httpd = server_class(server_address, handler_class) + return httpd.handle_request() + + +url = 'https://cas.amu.edu.pl/cas/login?service=http://localhost:3000&locale=pl' + +webbrowser.open_new_tab(url) +wait_for_request()