File: auth.py

package info (click to toggle)
python-awair 0.2.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,016 kB
  • sloc: python: 1,041; makefile: 12
file content (24 lines) | stat: -rw-r--r-- 710 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Authentication constructs for the Awair API."""

from abc import ABC, abstractmethod


class AwairAuth(ABC):
    """Abstract authentication that provides a Bearer token."""

    @abstractmethod
    async def get_bearer_token(self) -> str:
        """Return a valid bearer token for authentication."""


class AccessTokenAuth(AwairAuth):
    """Authentication that uses an Awair access token."""

    def __init__(self, access_token: str) -> None:
        """Initialize and save off our acces token."""
        self.access_token = access_token
        super().__init__()

    async def get_bearer_token(self) -> str:
        """Return the access token for authentication."""
        return self.access_token