python-google-weather-api 0.0.8__py3-none-any.whl → 0.0.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
google_weather_api/api.py CHANGED
@@ -23,6 +23,8 @@ from .model import (
23
23
  _LOGGER = logging.getLogger(__name__)
24
24
 
25
25
  _BASE_URL = "https://weather.googleapis.com/v1"
26
+ # See https://docs.cloud.google.com/docs/authentication/api-keys-use
27
+ _API_KEY_HEADER = "X-Goog-Api-Key"
26
28
  _USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36"
27
29
 
28
30
 
@@ -49,7 +51,10 @@ class GoogleWeatherApi:
49
51
  async def _async_get(self, endpoint: str, params: dict[str, Any], *, include_language_code: bool = True) -> dict[str, Any]:
50
52
  """Perform a GET request."""
51
53
  url = f"{_BASE_URL}/{endpoint}"
52
- headers = {aiohttp.hdrs.USER_AGENT: _USER_AGENT}
54
+ # Send the API key in a header rather than the "key" query parameter so it
55
+ # never ends up in a URL, which aiohttp includes in exceptions such as
56
+ # ContentTypeError and which callers commonly log.
57
+ headers = {aiohttp.hdrs.USER_AGENT: _USER_AGENT, _API_KEY_HEADER: self.api_key}
53
58
  if self.referrer:
54
59
  headers[aiohttp.hdrs.REFERER] = self.referrer
55
60
  params = {
@@ -58,9 +63,7 @@ class GoogleWeatherApi:
58
63
  }
59
64
  if include_language_code:
60
65
  params["language_code"] = self.language_code
61
- # Log before adding the API key so it doesn't end up in debug logs.
62
66
  _LOGGER.debug("GET %s with params: %s", url, params)
63
- params["key"] = self.api_key
64
67
  try:
65
68
  async with self.session.get(
66
69
  url,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-google-weather-api
3
- Version: 0.0.8
3
+ Version: 0.0.9
4
4
  Summary: A python client library for Google Weather API
5
5
  Author-email: tronikos <tronikos@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -0,0 +1,10 @@
1
+ google_weather_api/__init__.py,sha256=Su4PjNcbIJFYoFCEH4wwdtT-M2HSMtLNLvF-TWGHiNo,1601
2
+ google_weather_api/api.py,sha256=4_Y8TN6Mtrf4JDGoBOVm6W0uedxe5sPxMVx-ktD2kCI,7478
3
+ google_weather_api/exceptions.py,sha256=AHHzb-cbE0bgzp4PH2IC5s3jHAJHONbL9iw5b-_MvoU,534
4
+ google_weather_api/model.py,sha256=2Dx6VGh5Uaotb3McZSNs0BT6iJTrr5spYEUUC-IlXiA,24858
5
+ google_weather_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ python_google_weather_api-0.0.9.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
+ python_google_weather_api-0.0.9.dist-info/METADATA,sha256=SvCCnXAfToJfdwSvgBJ1D41y3lR3IsJGxgBwl_WJY5E,1412
8
+ python_google_weather_api-0.0.9.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
9
+ python_google_weather_api-0.0.9.dist-info/top_level.txt,sha256=ZkFbtKDHz3vUJhH6DGEPVLj3PPeNpR9-Wg0f4HqGD78,19
10
+ python_google_weather_api-0.0.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- google_weather_api/__init__.py,sha256=Su4PjNcbIJFYoFCEH4wwdtT-M2HSMtLNLvF-TWGHiNo,1601
2
- google_weather_api/api.py,sha256=NOSVkaj7YKHy6DL8J6x2HnUfA0V_J4GRFcsMS_EpyCs,7235
3
- google_weather_api/exceptions.py,sha256=AHHzb-cbE0bgzp4PH2IC5s3jHAJHONbL9iw5b-_MvoU,534
4
- google_weather_api/model.py,sha256=2Dx6VGh5Uaotb3McZSNs0BT6iJTrr5spYEUUC-IlXiA,24858
5
- google_weather_api/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
- python_google_weather_api-0.0.8.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
7
- python_google_weather_api-0.0.8.dist-info/METADATA,sha256=T33mjBiV5-p4PY__jHyKzYsvqI2sWOT-JGsskuGgYfk,1412
8
- python_google_weather_api-0.0.8.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
9
- python_google_weather_api-0.0.8.dist-info/top_level.txt,sha256=ZkFbtKDHz3vUJhH6DGEPVLj3PPeNpR9-Wg0f4HqGD78,19
10
- python_google_weather_api-0.0.8.dist-info/RECORD,,