Skip to content

authentication

OAuth2 authentication to access protected resources.

add_auth_to_url(url: str) -> str

Add authentication information to a URL.

Parameters:

url

The URL to add authentication information to.

TYPE: str

Returns:

str

The URL with authentication information added, or the original URL if no token is cached

get_cached_token(account_name: str) -> Optional[str]

Return the cached token for the account.

get_hosts_file() -> Path

Return the path to the hosts file.

github_auth_device(n_polls: int = 9999) -> Optional[str]

Authenticate with GitHub, polling up to n_polls times to wait for completion.

login_to_svc(
    service: Optional[str] = None,
    protocol: Optional[str] = None,
    scopes: Optional[str] = None,
    token: Optional[str] = None,
) -> str

Log in and cache token.

Parameters:

service

The name of the service to authenticate with

TYPE: Optional[str]

DEFAULT: None

protocol

The protocol to use for git operations

TYPE: Optional[str]

DEFAULT: None

scopes

Additional authentication scopes to request

TYPE: Optional[str]

DEFAULT: None

token

A specific token to use instead of logging in

TYPE: Optional[str]

DEFAULT: None

Returns:

str

The token for the service