Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions adafruit_gc_iot_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,22 +345,27 @@ def generate_jwt(self, ttl=43200, algo="RS256"):
self.logger.debug("Generating JWT...")

if self._esp is not None:
# Not all boards have ESP access easily (eg: featherS2). If we pass in a False or None in init, lets
# Not all boards have ESP access easily (eg: featherS2).
# If we pass in a False or None in init, lets
# assume that we've handled setting the RTC outside of here
# pylint: disable=import-outside-toplevel
import adafruit_ntp as NTP

ntp = NTP.NTP(self._esp)
ntp.set_time()
else:
if self.logger:
self.logger.info(f"No self._esp instance found, assuming RTC has been previously set")
self.logger.info(
"No self._esp instance found, assuming RTC has been previously set"
)

claims = {
# The time that the token was issued at
"iat": time.time(),
# The time the token expires.
"exp": time.time() + ttl,
# The audience field should always be set to the GCP project id.
"aud": self._proj_id
"aud": self._proj_id,
}
jwt = JWT.generate(claims, self._private_key, algo)
return jwt