mirror of
https://github.com/Andre0512/pyhOn.git
synced 2024-01-19 02:50:44 +00:00
Encode username/password
This commit is contained in:
parent
6b2c60d552
commit
33454f68b8
|
@ -5,6 +5,7 @@ import secrets
|
||||||
import urllib
|
import urllib
|
||||||
from pprint import pformat
|
from pprint import pformat
|
||||||
from urllib import parse
|
from urllib import parse
|
||||||
|
from urllib.parse import quote
|
||||||
|
|
||||||
from yarl import URL
|
from yarl import URL
|
||||||
|
|
||||||
|
@ -113,8 +114,8 @@ class HonAuth:
|
||||||
"descriptor": "apex://LightningLoginCustomController/ACTION$login",
|
"descriptor": "apex://LightningLoginCustomController/ACTION$login",
|
||||||
"callingDescriptor": "markup://c:loginForm",
|
"callingDescriptor": "markup://c:loginForm",
|
||||||
"params": {
|
"params": {
|
||||||
"username": self._email,
|
"username": quote(self._email),
|
||||||
"password": self._password,
|
"password": quote(self._password),
|
||||||
"startUrl": parse.unquote(
|
"startUrl": parse.unquote(
|
||||||
login_url.split("startURL=")[-1]
|
login_url.split("startURL=")[-1]
|
||||||
).split("%3D")[0],
|
).split("%3D")[0],
|
||||||
|
|
|
@ -13,17 +13,19 @@ class HonBaseConnectionHandler:
|
||||||
_HEADERS = {"user-agent": const.USER_AGENT, "Content-Type": "application/json"}
|
_HEADERS = {"user-agent": const.USER_AGENT, "Content-Type": "application/json"}
|
||||||
|
|
||||||
def __init__(self, session=None):
|
def __init__(self, session=None):
|
||||||
|
self._create_session = session is None
|
||||||
self._session = session
|
self._session = session
|
||||||
self._auth = None
|
self._auth = None
|
||||||
|
|
||||||
async def __aenter__(self):
|
async def __aenter__(self):
|
||||||
self._session = aiohttp.ClientSession()
|
|
||||||
return await self.create()
|
return await self.create()
|
||||||
|
|
||||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||||
await self.close()
|
await self.close()
|
||||||
|
|
||||||
async def create(self):
|
async def create(self):
|
||||||
|
if self._create_session:
|
||||||
|
self._session = aiohttp.ClientSession()
|
||||||
return self
|
return self
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
|
@ -41,6 +43,7 @@ class HonBaseConnectionHandler:
|
||||||
yield response
|
yield response
|
||||||
|
|
||||||
async def close(self):
|
async def close(self):
|
||||||
|
if self._create_session:
|
||||||
await self._session.close()
|
await self._session.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -7,7 +7,7 @@ with open("README.md", "r") as f:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="pyhOn",
|
name="pyhOn",
|
||||||
version="0.7.1",
|
version="0.7.2",
|
||||||
author="Andre Basche",
|
author="Andre Basche",
|
||||||
description="Control hOn devices with python",
|
description="Control hOn devices with python",
|
||||||
long_description=long_description,
|
long_description=long_description,
|
||||||
|
|
Loading…
Reference in a new issue