fix: short-circuit get_master_token() when master_token already stored - #1042
Open
githubhjs wants to merge 1 commit into
Open
fix: short-circuit get_master_token() when master_token already stored#1042githubhjs wants to merge 1 commit into
githubhjs wants to merge 1 commit into
Conversation
glocaltokens 0.7.6 has a guard `if self.username is None or self.password is None` that returns early before checking whether master_token is already populated. When the integration is configured with a master token but no password (e.g. via the manual token flow), get_master_token() always returns None, causing every auth attempt to raise InvalidMasterToken. Fix: check self._client.master_token directly first; only fall through to the library when no valid aas_et token is present. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
glocaltokens0.7.6 has an early-return guard inget_master_token():This fires before the method checks whether
master_tokenis already populated. As a result, when the integration is configured with a validaas_et/...master token but an emptypassword(which is the case when users obtain the token via the browser OAuth /gpsoauth.exchange_token()workaround), every call toget_master_token()returnsNoneand raisesInvalidMasterToken— even though the token is sitting right there inself._client.master_token.Fix
Short-circuit before delegating to the library: if
self._client.master_tokenalready holds a validaas_ettoken, return it directly.is_aas_etis already imported in this file, so no new imports are needed.Repro
gpsoauth.exchange_token()(needed because the standard Android login endpoint now returnsBadAuthentication)master_token=<aas_et/...>,password=""InvalidMasterTokenNotes
glocaltokens— a fix there would be cleaner. This is a targeted workaround inapi.pythat unblocks users until the dependency is updated.ha-google-homev1.13.3 withglocaltokens0.7.6.