Ring OTP improvement (#30688)

* Fix otp flow

* Update Ring to 0.5

Co-authored-by: steve-gombos <3118886+steve-gombos@users.noreply.github.com>
This commit is contained in:
Paulus Schoutsen 2020-01-11 18:22:08 -08:00 committed by GitHub
parent abe727fbbc
commit 9266fc0cd7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 11 deletions

View File

@ -1,7 +1,7 @@
"""Config flow for Ring integration.""" """Config flow for Ring integration."""
import logging import logging
from oauthlib.oauth2 import AccessDeniedError from oauthlib.oauth2 import AccessDeniedError, MissingTokenError
from ring_doorbell import Auth from ring_doorbell import Auth
import voluptuous as vol import voluptuous as vol
@ -15,18 +15,14 @@ _LOGGER = logging.getLogger(__name__)
async def validate_input(hass: core.HomeAssistant, data): async def validate_input(hass: core.HomeAssistant, data):
"""Validate the user input allows us to connect.""" """Validate the user input allows us to connect."""
def otp_callback():
if "2fa" in data:
return data["2fa"]
raise Require2FA
auth = Auth() auth = Auth()
try: try:
token = await hass.async_add_executor_job( token = await hass.async_add_executor_job(
auth.fetch_token, data["username"], data["password"], otp_callback, auth.fetch_token, data["username"], data["password"], data.get("2fa"),
) )
except MissingTokenError:
raise Require2FA
except AccessDeniedError: except AccessDeniedError:
raise InvalidAuth raise InvalidAuth

View File

@ -2,7 +2,7 @@
"domain": "ring", "domain": "ring",
"name": "Ring", "name": "Ring",
"documentation": "https://www.home-assistant.io/integrations/ring", "documentation": "https://www.home-assistant.io/integrations/ring",
"requirements": ["ring_doorbell==0.4.0"], "requirements": ["ring_doorbell==0.5.0"],
"dependencies": ["ffmpeg"], "dependencies": ["ffmpeg"],
"codeowners": [], "codeowners": [],
"config_flow": true "config_flow": true

View File

@ -1753,7 +1753,7 @@ rfk101py==0.0.1
rflink==0.0.50 rflink==0.0.50
# homeassistant.components.ring # homeassistant.components.ring
ring_doorbell==0.4.0 ring_doorbell==0.5.0
# homeassistant.components.fleetgo # homeassistant.components.fleetgo
ritassist==0.9.2 ritassist==0.9.2

View File

@ -570,7 +570,7 @@ restrictedpython==5.0
rflink==0.0.50 rflink==0.0.50
# homeassistant.components.ring # homeassistant.components.ring
ring_doorbell==0.4.0 ring_doorbell==0.5.0
# homeassistant.components.yamaha # homeassistant.components.yamaha
rxv==0.6.0 rxv==0.6.0