Fix 403 error when fetching spa data (wrong spa ID resolved from profile) - #2
Open
fsoderblom wants to merge 1 commit into
Open
Fix 403 error when fetching spa data (wrong spa ID resolved from profile)#2fsoderblom wants to merge 1 commit into
fsoderblom wants to merge 1 commit into
Conversation
get_profile() was using the account's own user "_id" as the spa ID, which is a different ID namespace. Fetching spa data with that ID returns 403 Forbidden even with valid credentials. Resolve the actual spa ID from the /spas list instead, as done prior to 272786e.
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
Integration setup kept failing with:
403 Client Error: Forbidden for url: https://iot.controlmyspa.com/spas/<id>Login and profile fetch succeeded, but fetching the actual spa data was
rejected with 403 (as opposed to 401, which is what invalid/missing auth
returns).
Root cause
get_profile()(introduced in 272786e) setsself.spa_idfrom theuser profile's
data.user._id. That field is the account's own user ID,not the spa ID — a different ID namespace. Requesting spa data with the
wrong ID returns 403 Forbidden even with valid credentials.
The existing fallback in
fetch_spa_data()only handles the case wherethe (wrong) ID returns an empty 200 response — it never triggers on 403,
so setup gets stuck retrying indefinitely.
Fix
get_profile()now resolves the spa ID from the/spaslist (as theintegration did before 272786e), matching the ID namespace actually
used by the spa data endpoint.
Test plan