-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Documentation for Application Credentials platform initial features #1279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
allenporter
merged 16 commits into
home-assistant:master
from
allenporter:developer_credentials
Apr 30, 2022
Merged
Changes from 13 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ed9fde8
Documentation for initial developer credentials platform
allenporter c701c3f
Fix typo
allenporter db05ef6
Update docs/core/platform/developer_credentials.md
allenporter 0cc5a85
Add static example for AuthorizationServer
allenporter ec811fc
Merge branch 'developer_credentials' of github.com:allenporter/develo…
allenporter d7afabe
Rename developer credentials to client credentials
allenporter b2349f5
Rename component to application credentials
allenporter 7acbe01
Update documentation to explain the import API
allenporter 11fd12d
Update docs/core/platform/application_credentials.md
allenporter 7d25ad4
Merge branch 'developer_credentials' of github.com:allenporter/develo…
allenporter 4833794
Add missing import statement and remove unused import
allenporter 02158c2
Update docs/core/platform/application_credentials.md
allenporter ca080a4
Update docs/core/platform/application_credentials.md
allenporter e35b60a
Rewrote documentation structure based on PR feedback
allenporter 008360b
Additional wording improvements
allenporter 8fc9d84
Update documentation for developer credentials after PR discussion fe…
allenporter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| --- | ||
| title: "Application Credentials" | ||
| --- | ||
|
|
||
| Integrations support [Configuration via OAuth2](https://developers.home-assistant.io/docs/config_entries_config_flow_handler#configuration-via-oauth2) and the preferred approach is to use the Home Assistant Cloud Account Linking service. Integrations may also allow users to provide their own OAuth client credentials by adding a `application_credentials.py` and implementing the right functions. | ||
|
frenck marked this conversation as resolved.
Outdated
|
||
|
|
||
| :::note | ||
| Application Credentials is under active development and integrations should still prefer using `LocalOAuth2Implementation`. | ||
| ::: | ||
|
|
||
| ## Adding support | ||
|
|
||
| Integrations support application credentials with a file in the integration folder called `application_credentials.py` and implement the following: | ||
|
|
||
| ```python | ||
| from homeassistant.core import HomeAssistant | ||
| from homeassistant.components.application_credentials import AuthorizationServer | ||
|
|
||
|
|
||
| async def async_get_authorization_server( | ||
| self, hass: HomeAssistant | ||
| ) -> AuthorizationServer: | ||
| """Return authorization server.""" | ||
| return AuthorizationServer( | ||
| authorize_url="https://example.com/auth", | ||
| token_url="https://example.com/oauth2/v4/token" | ||
| ) | ||
| ``` | ||
|
|
||
| See below for details on backwards compatibility with YAML credentials. | ||
|
|
||
| ## AuthorizationServer | ||
|
allenporter marked this conversation as resolved.
Outdated
|
||
|
|
||
| An `AuthorizationServer` represents the [OAuth2 Authorization server](https://datatracker.ietf.org/doc/html/rfc6749) used for an integration. | ||
|
|
||
| | Name | Type | | Description | | ||
| | ------------- | ---- | -------------------------------------------------------------------------------------------------- | ----------- | | ||
| | authorize_url | str | **Required** | The OAuth authorize URL that the user is redirected to during the configuration flow. | | ||
| | token_url | str | **Required** | The URL used for obtaining an access token. | | ||
|
|
||
| ## Import YAML credentials | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 |
||
|
|
||
| Credentials may be imported by integrations that used to accept YAML credentials using the import API `async_import_client_credential` provided by the application credentials integration. | ||
|
|
||
| The `auth_domain` is the domain for the auth implementation in the config entry, which is typically the domain specified in an existing `LocalOAuth2Implementation`. | ||
|
|
||
| ## ClientCredential | ||
|
|
||
| A `ClientCredential` represents a client credential provided by the user. | ||
|
|
||
| | Name | Type | | Description | | ||
| | ------------- | ---- | ------------------------------------------------------------------------- | ----------- | | ||
| | client_id | str | **Required** | The OAuth Client ID provided by the user. | | ||
| | client_secret | str | **Required** | The OAuth Client Secret provided by the user. | | ||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first sentence is missing something. Now it sounds like all integrations support oauth2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also here, we should clarify the sentence about cloud account linking, as implementing a local implementation isn't optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies, I deleted the wrong thing, i'll get back to this after sleeping on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i revamped this to add more of the bigger picture overview. I also updated the config flow docs to point here, then added a link back here with details on cloud account linking and nabu casa. Really, I think the cloud account linking stuff may deserve its own page. Or we could move more of that detail here, with a dedicated section, even though it does not technically involve this platform it may be the natural place to show the progression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a separate page about account linking may be needed. Although it's not so much for the contributor to do. It's mostly Nabu Casa that needs to set up an application. For now this is good, I think.