Skip to content

chore: Expose oauth constants#725

Merged
CFenner merged 4 commits intoopenviess:masterfrom
lackas:align-viessmann-scope
Mar 18, 2026
Merged

chore: Expose oauth constants#725
CFenner merged 4 commits intoopenviess:masterfrom
lackas:align-viessmann-scope

Conversation

@lackas
Copy link
Copy Markdown
Contributor

@lackas lackas commented Mar 18, 2026

Move AUTHORIZE_URL, TOKEN_URL, and VIESSMANN_SCOPE to PyViCareAbstractOAuthManager as the single source of truth. Both PyViCareOAuthManager and PyViCareBrowserOAuthManager now import from there.

This aligns the scope to ["IoT User", "offline_access"] for both managers. Previously, the password-grant manager used only ["IoT User"], which meant tokens had no refresh capability — they expired after 1h with no way to renew without re-authenticating with username/password.

Adding offline_access to the password-grant flow gives it a refresh token too, improving reliability for long-running sessions.

Related: #724, home-assistant/core#165621

Move AUTHORIZE_URL, TOKEN_URL, and VIESSMANN_SCOPE to
PyViCareAbstractOAuthManager as the single source of truth.
Both PyViCareOAuthManager and PyViCareBrowserOAuthManager now
import from there.

This aligns the scope to ["IoT User", "offline_access"] for both
managers. Previously, the password-grant manager used only
["IoT User"], which meant tokens had no refresh capability.
Copy link
Copy Markdown
Member

@CFenner CFenner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather replace the usage of VIESSMANN_SCOPE with the actual scope lists ([SCOPE_IOT, SCOPE_OFFLINE_ACCESS]).

API_BASE_URL = 'https://api.viessmann-climatesolutions.com/iot/v2'
AUTHORIZE_URL = 'https://iam.viessmann-climatesolutions.com/idp/v3/authorize'
TOKEN_URL = 'https://iam.viessmann-climatesolutions.com/idp/v3/token'
VIESSMANN_SCOPE = ["IoT User", "offline_access"]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets properly define all available scopes:

Suggested change
VIESSMANN_SCOPE = ["IoT User", "offline_access"]
SCOPE_IOT = "IoT"
SCOPE_USER = "User"
SCOPE_OFFLINE_ACCESS = "offline_access"
SCOPE_INTERNAL = "internal"

Replace VIESSMANN_SCOPE list with individual constants:
SCOPE_IOT, SCOPE_USER, SCOPE_OFFLINE_ACCESS, SCOPE_INTERNAL.

Each manager builds its own scope list from these constants,
making it explicit which scopes each flow requests.
@CFenner CFenner changed the title Unify VIESSMANN_SCOPE and OAuth constants in abstract base Expose different scopes as constants Mar 18, 2026
Co-authored-by: Christopher Fenner <9592452+CFenner@users.noreply.github.com>
@CFenner CFenner changed the title Expose different scopes as constants Expose oauth constants Mar 18, 2026
@CFenner CFenner merged commit 7cefe90 into openviess:master Mar 18, 2026
9 of 10 checks passed
@CFenner CFenner changed the title Expose oauth constants chore: Expose oauth constants Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants