Skip to content

ProviderAuthBackend

Sub classes

Name Children Inherits
CopilotAuthBackend
llmling_models.auth.github_auth
GitHub Copilot device-code auth backend.
    OpenAICodexAuthBackend
    llmling_models.auth.openai_codex_auth
    OpenAI Codex (ChatGPT Plus/Pro) OAuth backend.
      PoeAuthBackend
      llmling_models.auth.poe_auth
      Poe OAuth / API key auth backend.
        ZenAuthBackend
        llmling_models.auth.zen_auth
        OpenCode Zen API key auth backend.

          Base classes

          Name Children Inherits
          ABC
          abc
          Helper class that provides a standard way to create an ABC using

          ⋔ Inheritance diagram

          graph TD
            1157112198["base.ProviderAuthBackend"]
            925645236["abc.ABC"]
            2751680898["builtins.object"]
            925645236 --> 1157112198
            2751680898 --> 925645236

          🛈 DocStrings

          Bases: ABC

          Protocol for a provider-specific auth backend.

          Source code in src/llmling_models/auth/base.py
          class ProviderAuthBackend(ABC):
              """Protocol for a provider-specific auth backend."""
          
              @property
              @abstractmethod
              def provider_id(self) -> str:
                  """Unique provider identifier."""
                  ...
          
              @abstractmethod
              def methods(self) -> list[ProviderAuthMethod]:
                  """Return available auth methods for this provider."""
                  ...
          
              @abstractmethod
              async def authorize(self, method: int = 0) -> ProviderAuthAuthorization:
                  """Start an authorization flow.
          
                  Args:
                      method: Index into the methods list.
          
                  Returns:
                      Authorization info with URL and instructions.
                  """
                  ...
          
              @abstractmethod
              async def callback(
                  self,
                  *,
                  code: str | None = None,
                  device_code: str | None = None,
                  verifier: str | None = None,
              ) -> bool:
                  """Handle the auth callback / code exchange.
          
                  Returns:
                      True if auth succeeded.
          
                  Raises:
                      ValueError: If required parameters are missing or exchange fails.
                  """
                  ...
          
              async def set_credentials(self, info: AuthInfo) -> bool:
                  """Store credentials for this provider.
          
                  Default implementation is a no-op. Override for providers that
                  support direct credential setting (e.g. API key or token import).
                  """
                  return False
          
              async def remove_credentials(self) -> bool:
                  """Remove stored credentials for this provider.
          
                  Default implementation is a no-op.
                  """
                  return False
          

          provider_id abstractmethod property

          provider_id: str
          

          Unique provider identifier.

          authorize abstractmethod async

          authorize(method: int = 0) -> ProviderAuthAuthorization
          

          Start an authorization flow.

          Parameters:

          Name Type Description Default
          method int

          Index into the methods list.

          0

          Returns:

          Type Description
          ProviderAuthAuthorization

          Authorization info with URL and instructions.

          Source code in src/llmling_models/auth/base.py
          @abstractmethod
          async def authorize(self, method: int = 0) -> ProviderAuthAuthorization:
              """Start an authorization flow.
          
              Args:
                  method: Index into the methods list.
          
              Returns:
                  Authorization info with URL and instructions.
              """
              ...
          

          callback abstractmethod async

          callback(
              *, code: str | None = None, device_code: str | None = None, verifier: str | None = None
          ) -> bool
          

          Handle the auth callback / code exchange.

          Returns:

          Type Description
          bool

          True if auth succeeded.

          Raises:

          Type Description
          ValueError

          If required parameters are missing or exchange fails.

          Source code in src/llmling_models/auth/base.py
          @abstractmethod
          async def callback(
              self,
              *,
              code: str | None = None,
              device_code: str | None = None,
              verifier: str | None = None,
          ) -> bool:
              """Handle the auth callback / code exchange.
          
              Returns:
                  True if auth succeeded.
          
              Raises:
                  ValueError: If required parameters are missing or exchange fails.
              """
              ...
          

          methods abstractmethod

          methods() -> list[ProviderAuthMethod]
          

          Return available auth methods for this provider.

          Source code in src/llmling_models/auth/base.py
          @abstractmethod
          def methods(self) -> list[ProviderAuthMethod]:
              """Return available auth methods for this provider."""
              ...
          

          remove_credentials async

          remove_credentials() -> bool
          

          Remove stored credentials for this provider.

          Default implementation is a no-op.

          Source code in src/llmling_models/auth/base.py
          async def remove_credentials(self) -> bool:
              """Remove stored credentials for this provider.
          
              Default implementation is a no-op.
              """
              return False
          

          set_credentials async

          set_credentials(info: AuthInfo) -> bool
          

          Store credentials for this provider.

          Default implementation is a no-op. Override for providers that support direct credential setting (e.g. API key or token import).

          Source code in src/llmling_models/auth/base.py
          async def set_credentials(self, info: AuthInfo) -> bool:
              """Store credentials for this provider.
          
              Default implementation is a no-op. Override for providers that
              support direct credential setting (e.g. API key or token import).
              """
              return False
          

          :fa-brands-github: Show source on GitHub