Convert SmartThings setup from PAT to OAuth credentials#36
Closed
Convert SmartThings setup from PAT to OAuth credentials#36
Conversation
Replace the Personal Access Token (PAT) setup step with an OAuth credentials step (App ID, Client ID, Client Secret) obtained from the SmartThings Developer Portal. Key changes: - config_flow.py: new async_step_oauth_credentials replaces async_step_pat; location selection removed (delivered via INSTALL webhook); async_step_install generates OAuth tokens directly - smartapp.py: add setup_smartapp_for_oauth(); update _find_and_continue_flow() to match OAuth flows by app_id; extend _continue_flow() with optional location_id parameter - pysmartapp/smartapp.py: add public_key setter to SmartApp - pysmartapp/request.py: skip signature verification when public_key is None (initial OAuth setup window) - pysmartthings/installedapp.py: make location_id optional in format_install_url() - __init__.py: update SmartApp public key after OAuth token acquired - strings.json, translations/en.json, translations/ko.json: new oauth_credentials step UI strings Agent-Logs-Url: https://github.com/oukene/smartthings_customize/sessions/6e4566b2-151d-4214-b459-53f3c4fe4cc6 Co-authored-by: oukene <19838374+oukene@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Update authentication method to OAuth for SmartThings integration
Convert SmartThings setup from PAT to OAuth credentials
Mar 31, 2026
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.
The integration required a Personal Access Token (PAT) to dynamically create a SmartApp and generate OAuth credentials at setup time. This replaces that flow with direct OAuth credentials (App ID, Client ID, Client Secret) pre-registered in the SmartThings Developer Portal.
Config flow (
config_flow.py)async_step_pat+async_step_select_location→async_step_oauth_credentialslocation_idis delivered via the INSTALL webhook callback and forwarded intoasync_step_authorizeasync_step_installexchanges the receivedrefresh_tokenfor anaccess_tokenviagenerate_tokens()before creating the config entryapp_idstored in flow context so the webhook dispatcher can match callbacks to in-progress flowsWebhook / SmartApp registration (
smartapp.py,pysmartapp/)setup_smartapp_for_oauth(hass, app_id)registers a SmartApp withpublic_key=Noneso INSTALL callbacks can be dispatched before an access token is available_find_and_continue_flowgains a fallback: matches anauthorize-step flow bycontext["app_id"]whenunique_idis not yet set, and forwardslocation_idvia_continue_flowsetup_smartappnow updatespublic_keyon an already-registered SmartApppublic_key is None; re-enabled inasync_setup_entryonce the full app info is fetched with the OAuth tokenOther
format_install_url:location_idmade optional — lets SmartThings prompt the user to pick a location on its authorization pageSmartApp.public_keymade settableasync_setup_entry: applieswebhook_public_keyto a SmartApp registered without one during OAuth setupstrings.json,translations/en.json,translations/ko.json: newoauth_credentialsstep strings; PAT/location-selection strings removed