Fix sync oath2 scaffold template (#46219)

This commit is contained in:
Martin Hjelmare 2021-02-08 15:00:17 +01:00 committed by GitHub
parent 6f446cf627
commit 568180632e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 8 deletions

View File

@ -65,7 +65,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation) session = config_entry_oauth2_flow.OAuth2Session(hass, entry, implementation)
# If using a requests-based API lib # If using a requests-based API lib
hass.data[DOMAIN][entry.entry_id] = api.ConfigEntryAuth(hass, entry, session) hass.data[DOMAIN][entry.entry_id] = api.ConfigEntryAuth(hass, session)
# If using an aiohttp-based API lib # If using an aiohttp-based API lib
hass.data[DOMAIN][entry.entry_id] = api.AsyncConfigEntryAuth( hass.data[DOMAIN][entry.entry_id] = api.AsyncConfigEntryAuth(

View File

@ -4,7 +4,7 @@ from asyncio import run_coroutine_threadsafe
from aiohttp import ClientSession from aiohttp import ClientSession
import my_pypi_package import my_pypi_package
from homeassistant import config_entries, core from homeassistant import core
from homeassistant.helpers import config_entry_oauth2_flow from homeassistant.helpers import config_entry_oauth2_flow
# TODO the following two API examples are based on our suggested best practices # TODO the following two API examples are based on our suggested best practices
@ -18,15 +18,11 @@ class ConfigEntryAuth(my_pypi_package.AbstractAuth):
def __init__( def __init__(
self, self,
hass: core.HomeAssistant, hass: core.HomeAssistant,
config_entry: config_entries.ConfigEntry, oauth_session: config_entry_oauth2_flow.OAuth2Session,
implementation: config_entry_oauth2_flow.AbstractOAuth2Implementation,
): ):
"""Initialize NEW_NAME Auth.""" """Initialize NEW_NAME Auth."""
self.hass = hass self.hass = hass
self.config_entry = config_entry self.session = oauth_session
self.session = config_entry_oauth2_flow.OAuth2Session(
hass, config_entry, implementation
)
super().__init__(self.session.token) super().__init__(self.session.token)
def refresh_tokens(self) -> str: def refresh_tokens(self) -> str: