Skip to content

Commit 48a3eca

Browse files
committed
Fix some invlaid attribute access
1 parent 426a722 commit 48a3eca

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

adafruit_gc_iot_core.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ def __init__(self, mqtt_client):
6060
)
6161
# Verify that the MiniMQTT client was setup correctly.
6262
try:
63-
self.user = self._client.user
63+
# I have no idea where _client.user comes from, but ._username exists when .user doesn't
64+
self.user = self._client._username
6465
except Exception as err:
6566
raise TypeError(
6667
"Google Cloud Core IoT MQTT API requires a username."
6768
) from err
6869
# Validate provided JWT before connecting
6970
try:
70-
JWT.validate(self._client.password)
71+
JWT.validate(self._client._password) # Again, .password isn't valid here..
7172
except Exception as err:
7273
raise TypeError("Invalid JWT provided.") from err
7374
# If client has KeepAlive =0 or if KeepAlive > 20min,
@@ -350,15 +351,15 @@ def generate_jwt(self, ttl=43200, algo="RS256"):
350351
ntp = NTP.NTP(self._esp)
351352
ntp.set_time()
352353
else:
353-
self.logger.info(f"No self._esp instance found, assuming RTC has been previously set")
354+
if self.logger:
355+
self.logger.info(f"No self._esp instance found, assuming RTC has been previously set")
354356

355357
claims = {
356358
# The time that the token was issued at
357359
"iat": time.time(),
358360
# The time the token expires.
359361
"exp": time.time() + ttl,
360362
# The audience field should always be set to the GCP project id.
361-
"aud": self._proj_id,
362363
}
363364
jwt = JWT.generate(claims, self._private_key, algo)
364365
return jwt

0 commit comments

Comments
 (0)