Skip to content

Commit

Permalink
Merge pull request #10 from astrandb/urlencode
Browse files Browse the repository at this point in the history
Url-encode request parameters
  • Loading branch information
astrandb authored May 8, 2022
2 parents 69427c4 + bd0651d commit 66975ba
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion custom_components/weatherlink/pyweatherlink.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Move to pypi.org when stable
"""
import logging
import urllib.parse

from aiohttp import ClientResponse, ClientResponseError, ClientSession

Expand Down Expand Up @@ -38,9 +39,16 @@ async def request(self, method, **kwargs) -> ClientResponse:
headers = dict(headers)
kwargs.pop("headers")

params = {
'user': self.username,
'pass': self.password,
'apiToken': self.apitoken,
}
params_enc = urllib.parse.urlencode(params, quote_via=urllib.parse.quote)

res = await self.websession.request(
method,
f"{API_URL}?user={self.username}&pass={self.password}&apiToken={self.apitoken}",
f"{API_URL}?{params_enc}",
**kwargs,
headers=headers,
)
Expand Down

0 comments on commit 66975ba

Please sign in to comment.