How to replicate:
from squarelet import SquareletClient
good = SquareletClient(base_uri=BASE_URI, username=USER, password=PW)
# good UA -> "... <username>" (correct)
rebuilt = SquareletClient(base_uri=BASE_URI) # no creds -> "... Anonymous"
rebuilt.refresh_token = good.refresh_token
rebuilt._set_tokens()
print(rebuilt.session.headers["User-Agent"]) # "... Anonymous" <-- bug
print(rebuilt.session.headers["Authorization"]) # valid Bearer token
Proposed fix
Rebuild the UA deterministically from a captured base on every auth-state change, and when there's no local username, resolve one from users/me/ (cached). This labels any authenticated client correctly regardless of how it acquired its token.
How to replicate:
Proposed fix
Rebuild the UA deterministically from a captured base on every auth-state change, and when there's no local username, resolve one from users/me/ (cached). This labels any authenticated client correctly regardless of how it acquired its token.