Onboarding to generate auth code (#21777)
This commit is contained in:
1 parent
a0e8543aed
commit
3da0ed9cc7
4 files changed
+44
-2
No files matched your search
@@ -127,6 +127,7 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant.auth.models import User, Credentials, \
|
||||
TOKEN_TYPE_LONG_LIVED_ACCESS_TOKEN
|
||||
from homeassistant.loader import bind_hass
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.components.http import KEY_REAL_IP
|
||||
from homeassistant.components.http.auth import async_sign_path
|
||||
@@ -184,10 +185,18 @@ RESULT_TYPE_USER = 'user'
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@bind_hass
|
||||
def create_auth_code(hass, client_id: str, user: User) -> str:
|
||||
"""Create an authorization code to fetch tokens."""
|
||||
return hass.data[DOMAIN](client_id, user)
|
||||
|
||||
|
||||
async def async_setup(hass, config):
|
||||
"""Component to allow users to login."""
|
||||
store_result, retrieve_result = _create_auth_code_store()
|
||||
|
||||
hass.data[DOMAIN] = store_result
|
||||
|
||||
hass.http.register_view(TokenView(retrieve_result))
|
||||
hass.http.register_view(LinkUserView(retrieve_result))
|
||||
|
||||
|
||||
Reference in new issue
Block a user