-
-
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 all 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
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,52 @@ | ||
| --- | ||
| title: "Application Credentials" | ||
| --- | ||
|
|
||
| Integrations may support [Configuration via OAuth2](/docs/config_entries_config_flow_handler#configuration-via-oauth2) allowing | ||
| users to link their accounts. Integrations may add a `application_credentials.py` file and implement the functions described below. | ||
|
|
||
| OAuth2 requires credentials that are shared between an application and provider. In Home Assistant, integration specific OAuth2 credentials are provided using one or more approaches: | ||
|
|
||
| - *Local OAuth with Application Credentials Component*: Users create their own credentials with the cloud provider, often acting as an application developer, and register the credentials with Home Assistant and integration. This approach is *required* by all integrations that support OAuth2. | ||
| - *Cloud Account Linking with Cloud Component*: Nabu Casa registers credentials with the cloud provider, providing a seamless user experience. This approach provides a seamless user experience and is *recommended* ([more info](/docs/config_entries_config_flow_handler#configuration-via-oauth2)). | ||
|
|
||
| ## 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" | ||
| ) | ||
| ``` | ||
|
|
||
| ### AuthorizationServer | ||
|
|
||
| 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 | ||
|
|
||
| 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. | ||
|
|
||
| ### 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.
😍