MCPcopy Create free account
hub / github.com/comaps/comaps / FetchSessionId

Function FetchSessionId

tools/python/oauth2-flow/oauth2_flow.py:29–47  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27test_password = "12345678"
28
29def FetchSessionId():
30 logging.info("Getting initial cookie to login ...")
31
32 conn = http.client.HTTPSConnection(osmHost)
33 conn.request("GET", "/login?cookie_test=true")
34 res = conn.getresponse()
35
36 cookies = SimpleCookie()
37 cookies.load(res.headers['Set-Cookie'])
38
39 authToken = FindAuthenticityToken("/login", res.read().decode("utf-8"))
40
41 if authToken is None:
42 raise Exception("Can't find 'authenticity_token'")
43
44 logging.info(f"Parsed authToken = {authToken}")
45 logging.info("Got cookies: %s",res.headers['Set-Cookie'])
46
47 return cookies, authToken
48
49def LoginUserPassword(username, password, cookies, authToken):
50 logging.info("Logging in with username and password ...")

Callers 2

oauth2_flow.pyFile · 0.85
AuthorizePasswordMethod · 0.85

Calls 3

FindAuthenticityTokenFunction · 0.70
loadMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected