Update script scaffold templates for config_flow_oauth2 (#41181)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
This commit is contained in:
parent
d3bc4efa89
commit
42cef1773b
3 changed files with 6 additions and 6 deletions
|
@ -153,7 +153,7 @@ def _custom_tasks(template, info) -> None:
|
|||
)
|
||||
|
||||
elif template == "config_flow_oauth2":
|
||||
info.update_manifest(config_flow=True)
|
||||
info.update_manifest(config_flow=True, dependencies=["http"])
|
||||
info.update_strings(
|
||||
title=info.name,
|
||||
config={
|
||||
|
|
|
@ -29,13 +29,13 @@ class ConfigEntryAuth(my_pypi_package.AbstractAuth):
|
|||
)
|
||||
super().__init__(self.session.token)
|
||||
|
||||
def refresh_tokens(self) -> dict:
|
||||
def refresh_tokens(self) -> str:
|
||||
"""Refresh and return new NEW_NAME tokens using Home Assistant OAuth2 session."""
|
||||
run_coroutine_threadsafe(
|
||||
self.session.async_ensure_token_valid(), self.hass.loop
|
||||
).result()
|
||||
|
||||
return self.session.token
|
||||
return self.session.token["access_token"]
|
||||
|
||||
|
||||
class AsyncConfigEntryAuth(my_pypi_package.AbstractAuth):
|
||||
|
@ -50,9 +50,9 @@ class AsyncConfigEntryAuth(my_pypi_package.AbstractAuth):
|
|||
super().__init__(websession)
|
||||
self._oauth_session = oauth_session
|
||||
|
||||
async def async_get_access_token(self):
|
||||
async def async_get_access_token(self) -> str:
|
||||
"""Return a valid access token."""
|
||||
if not self._oauth_session.valid_token:
|
||||
await self._oauth_session.async_ensure_token_valid()
|
||||
|
||||
return self._oauth_session.token
|
||||
return self._oauth_session.token["access_token"]
|
||||
|
|
|
@ -13,7 +13,7 @@ CLIENT_ID = "1234"
|
|||
CLIENT_SECRET = "5678"
|
||||
|
||||
|
||||
async def test_full_flow(hass, aiohttp_client, aioclient_mock):
|
||||
async def test_full_flow(hass, aiohttp_client, aioclient_mock, current_request):
|
||||
"""Check full flow."""
|
||||
assert await setup.async_setup_component(
|
||||
hass,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue