Resolve the token for *entry*. Default implementation reads from ``entry.token`` directly or from the environment variable named by ``entry.token_env``. Override for schemes that acquire tokens dynamically (e.g. ``azure-cli``, ``azure-ad``).
(self, entry: AuthConfigEntry)
| 37 | """ |
| 38 | |
| 39 | def resolve_token(self, entry: AuthConfigEntry) -> str | None: |
| 40 | """Resolve the token for *entry*. |
| 41 | |
| 42 | Default implementation reads from ``entry.token`` directly |
| 43 | or from the environment variable named by ``entry.token_env``. |
| 44 | Override for schemes that acquire tokens dynamically |
| 45 | (e.g. ``azure-cli``, ``azure-ad``). |
| 46 | """ |
| 47 | import os |
| 48 | |
| 49 | if entry.token: |
| 50 | return entry.token.strip() or None |
| 51 | if entry.token_env: |
| 52 | val = os.environ.get(entry.token_env) |
| 53 | if val is not None: |
| 54 | val = val.strip() |
| 55 | if val: |
| 56 | return val |
| 57 | return None |