Skip to content
Back to top
View this page

# twine.auth module

twine.auth.TOKEN_RENEWAL_THRESHOLD: Final[timedelta] = datetime.timedelta(seconds=300)

  Tokens expire after 15 minutes, let’s start allowing renewal/replacement after 10 minutes that way if we fail, we may still have time to replace it before it expires. Thus, if our current time + this threshold is past the greater or equal to the expiration time, we should start trying to replace the token.

class twine.auth.CredentialInput
  __init__(username: str | None = None, password: str | None = None) → None

class twine.auth.TrustedPublishingTokenRetrievalError
  code: str
  description: str

class twine.auth.TrustedPublishingToken
  message: str | None
  errors: list[TrustedPublishingTokenRetrievalError] | None
  token: str | None
  success: bool | None
  expires: int | None

class twine.auth.TrustedPublishingAuthenticator
  __init__(resolver: Resolver) → None

class twine.auth.Resolver
  _tp_token: TrustedPublishingToken | None = None
  _expires: int | None = None
  __init__(config: Dict[str, str | None], input: CredentialInput) → None
  property authenticator: AuthBase
  classmethod choose(interactive: bool) → Type[Resolver]
  property username: str | None
  property password: str | None
  _has_valid_cached_tp_token() → bool
  _make_trusted_publishing_token() → TrustedPublishingToken | None
  make_trusted_publishing_token() → str | None
  property system: str | None
  get_username_from_keyring() → str | None
  get_password_from_keyring() → str | None
  username_from_keyring_or_prompt() → str
  password_from_keyring_or_trusted_publishing_or_prompt() → str
  prompt(what: str, how: Callable[[...], str]) → str
  is_pypi() → bool

    As of 2024-01-01, PyPI requires API tokens for uploads.

class twine.auth.Private
  prompt(what: str, how: Callable[[...], str] | None = None) → str