(
self,
app_id: int | str,
private_key: str | PrivateKeyGenerator | None = None,
*,
sign_func: DictSignFunction | None = None,
jwt_expiry: int = Consts.DEFAULT_JWT_EXPIRY,
jwt_issued_at: int = Consts.DEFAULT_JWT_ISSUED_AT,
)
| 216 | |
| 217 | # v3: move * above private_key |
| 218 | def __init__( |
| 219 | self, |
| 220 | app_id: int | str, |
| 221 | private_key: str | PrivateKeyGenerator | None = None, |
| 222 | *, |
| 223 | sign_func: DictSignFunction | None = None, |
| 224 | jwt_expiry: int = Consts.DEFAULT_JWT_EXPIRY, |
| 225 | jwt_issued_at: int = Consts.DEFAULT_JWT_ISSUED_AT, |
| 226 | ): |
| 227 | assert isinstance(app_id, (int, str)), app_id |
| 228 | if isinstance(app_id, str): |
| 229 | assert len(app_id) > 0, "app_id must not be empty" |
| 230 | assert private_key is not None or sign_func is not None, "either private_key or sign_func must be given" |
| 231 | assert private_key is None or sign_func is None, "private_key or sign_func cannot both be given" |
| 232 | if private_key is not None: |
| 233 | assert isinstance(private_key, str) or callable(private_key) |
| 234 | if isinstance(private_key, str): |
| 235 | assert len(private_key) > 0, "private_key must not be empty" |
| 236 | sign_func = AppAuth.create_jwt_sign(private_key, Consts.DEFAULT_JWT_ALGORITHM) |
| 237 | assert isinstance(jwt_expiry, int), jwt_expiry |
| 238 | assert Consts.MIN_JWT_EXPIRY <= jwt_expiry <= Consts.MAX_JWT_EXPIRY, jwt_expiry |
| 239 | |
| 240 | self._app_id = str(app_id) |
| 241 | self._sign_func = sign_func |
| 242 | self._jwt_expiry = jwt_expiry |
| 243 | self._jwt_issued_at = jwt_issued_at |
| 244 | |
| 245 | @property |
| 246 | def app_id(self) -> int | str: |
nothing calls this directly
no test coverage detected