feat: add OAuth support for cloud APIs - #563
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Warning
Important issues found.
- Token exchange sends no client authentication and no PKCE — and the helper signature can't express either
- Unknown-model diagnostic loses the payload that exists to add new device support
|
Thanks for the detailed review. I addressed the diagnostic and error-handling findings in On the OAuth wire contract: there is not currently a public SwitchBot OAuth document I can link. The implementation follows the SwitchBot-provisioned public-client flow used by the current consumer. Changes made from the review:
The token returned by this flow is expected directly in the SwitchBot internal account endpoints' Local result: |
Verified PKCE point accepted as a documented server limitation, not re-raised as blocking. Residual risk stays real: an intercepted code remains redeemable by anyone. Worth documenting that Two follow-ups from this pass. README line 89 still quotes |
|
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
|
@zerzhang You should have access to merge this once the bot approves. There are some nits above to address though |
PR Review — feat: add OAuth support for cloud APIsMerge-ready. Every earlier suggestion and silent-failure finding is resolved; only two small structural cleanups are left. Confirmed fixed in
What's done well: the password and token flows share Remaining (non-blocking):
✅ Resolved since last review (4)Previously-flagged issues verified fixed
🟢 Suggestions
1. Same two-clause passthrough appears three times; one tuple clause would do
|
bluetoothbot
left a comment
There was a problem hiding this comment.
Tip
No blocking issues found — ready to merge.
Human responsible: @zerzhang.
Summary
OAuth wire contract
state;statedoes not replace PKCE.authorizationheader expected by the SwitchBot internal account endpoints.Error semantics
HTTP 401 and 403 responses now surface as
SwitchbotAuthenticationError, including on the pre-existing password flow. Other provider API failures surface asSwitchbotApiError; transport and service-availability failures useSwitchbotAccountConnectionError.Testing
poetry run pytest --cov=switchbot testsswitchbot/oauth.pyand the new shared request-ID helper are fully covered