Skip to content

Documentation for Application Credentials platform initial features#1279

Merged
allenporter merged 16 commits intohome-assistant:masterfrom
allenporter:developer_credentials
Apr 30, 2022
Merged

Documentation for Application Credentials platform initial features#1279
allenporter merged 16 commits intohome-assistant:masterfrom
allenporter:developer_credentials

Conversation

@allenporter
Copy link
Copy Markdown
Contributor

@allenporter allenporter commented Apr 2, 2022

Proposed change

Propose initial documentation for application credentials platform. The platform is not quite ready for broad use, but has a placeholder with a note for now. This is mostly to make it easier for reviewing the platform and making it easier to determine if this is the right API for reviewers.

See home-assistant/architecture#692 (comment) for discussion.

Type of change

  • Document existing features within Home Assistant
  • Document new or changing features which there is an existing pull request elsewhere
  • Spelling or grammatical corrections, or rewording for improved clarity
  • Changes to the backend of this documentation
  • Removed stale or deprecated documentation

Additional information

Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>

## DeveloperCredential

A `DeveloperCredential` represents the a developer credential provided by the user. This is only provided for backward compatibility by integrations that allowed users to specify developer credentials via `configuration.yaml`.
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.

Hmm... should integration be able to import and deprecate the YAML configuration?

Copy link
Copy Markdown
Contributor Author

@allenporter allenporter Apr 3, 2022

Choose a reason for hiding this comment

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

Yes, definitely. This is called out as a task in the core PR, but didn't spell it out here yet:

Options I can see are:
(1) Use the existing platform method:

async def async_get_developer_credential(
    self, hass: HomeAssistant
) -> DeveloperCredential:

Could also be renamed to have import in the name.

(2) Offer a standalone method for the integration to call that accepts a credentials.

I have a method that in the implementation PR currently private that can be exposed:

async def _async_register_auth_implementation(
    hass: HomeAssistant,
    domain: str,
    developer_credential: DeveloperCredential,
) -> None:

Or we can rename it (e.g. stick "import" in the name). Integrations can call this from setup and create a credential from the data in the config which would be strictly easier, but more disconnected, from using the platform.


Are there gaps in these APIs needed to support import?

I did not mention this here yet because I thought there might be practical implications i have not worked out yet, so was going to work through in an integration first.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this more think that import needs a little more from the API, since it also needs to register the authentication domain. I think I will take the method that returns the credential out of the platform, and make it a static method that the integration calls from setup.

I next need to take another pass updating the docs to match what is proposed in the PR.

Copy link
Copy Markdown
Contributor Author

@allenporter allenporter Apr 5, 2022

Choose a reason for hiding this comment

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

I've updated this to reflect a separate import API. I think it makes sense as a separate method call since new integrations won't need to specify it in the platform.

I was assuming that I didn't need to go to the level of writing out a whole migration guide given the low # of users of the existing local oauth implementation, and that i might be helping with the migration myself anyway -- and i'd probably update as I go through the migration myself to work out the issues.

@allenporter allenporter changed the title Documentation for initial developer credentials platform Documentation for OAuth Client Credentials platform initial features Apr 3, 2022
@allenporter allenporter changed the title Documentation for OAuth Client Credentials platform initial features Documentation for Application Credentials platform initial features Apr 3, 2022
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.
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.

The first sentence is missing something. Now it sounds like all integrations support oauth2.

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.

Also here, we should clarify the sentence about cloud account linking, as implementing a local implementation isn't optional.

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

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.

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.

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.

allenporter and others added 2 commits April 7, 2022 01:02
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
| 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
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.

😍

@allenporter allenporter merged commit 416b087 into home-assistant:master Apr 30, 2022
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.

5 participants