File tree Expand file tree Collapse file tree
.openapi-generator-templates Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -625,14 +625,15 @@ conf = {{packageName}}.Configuration(
625625 """Live bearer credential, sent as `Authorization: Bearer <value >`.
626626
627627 Backed by the regeneration-immune `_TokenManager` (see `{ {packageName} }._auth`):
628- an `hd_` API token is transparently exchanged for a short-lived JWT and
628+ an opaque API token is transparently exchanged for a short-lived JWT and
629629 kept fresh, while a credential already shaped like a JWT (or exchange
630630 opted out) is returned unchanged. `auth_settings()` reads this on every
631631 request, so the wire always carries a current token.
632632 """
633- if self._token_manager is None:
634- return None
635- return self._token_manager.bearer_value()
633+ # Read the manager once: a concurrent `api_key` reset could otherwise
634+ # set it to None between the check and the `.bearer_value()` call.
635+ tm = self._token_manager
636+ return None if tm is None else tm.bearer_value()
636637
637638 @api_key.setter
638639 def api_key(self, value: Optional[str]) -> None:
Original file line number Diff line number Diff line change @@ -507,14 +507,15 @@ def api_key(self) -> Optional[str]:
507507 """Live bearer credential, sent as `Authorization: Bearer <value>`.
508508
509509 Backed by the regeneration-immune `_TokenManager` (see `hotdata._auth`):
510- an `hd_` API token is transparently exchanged for a short-lived JWT and
510+ an opaque API token is transparently exchanged for a short-lived JWT and
511511 kept fresh, while a credential already shaped like a JWT (or exchange
512512 opted out) is returned unchanged. `auth_settings()` reads this on every
513513 request, so the wire always carries a current token.
514514 """
515- if self ._token_manager is None :
516- return None
517- return self ._token_manager .bearer_value ()
515+ # Read the manager once: a concurrent `api_key` reset could otherwise
516+ # set it to None between the check and the `.bearer_value()` call.
517+ tm = self ._token_manager
518+ return None if tm is None else tm .bearer_value ()
518519
519520 @api_key .setter
520521 def api_key (self , value : Optional [str ]) -> None :
You can’t perform that action at this time.
0 commit comments