check for pyobjc before using it

This commit is contained in:
JJTech0130 2023-07-26 07:29:35 -04:00
parent baf922af61
commit ba1537ed58
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6

View file

@ -50,8 +50,16 @@ def get_auth_token(
) -> tuple[str, str]:
from sys import platform
# if use_gsa:
use_gsa = False
# Check if objc is importable
try:
if platform == "darwin":
import objc
use_gsa = True
except ImportError:
pass
if use_gsa:
logger.debug("Using GrandSlam to authenticate (native Anisette)")
g = gsa.authenticate(username, password, gsa.Anisette())
pet = g["t"]["com.apple.gs.idms.pet"]["token"]