# Buggy code
async def request_configuration(hass, config_entry, login):
    """Request configuration steps from the user using the configurator."""

    async def configuration_callback(callback_data):
        """Handle the submitted configuration."""
        await hass.async_add_job(
            setup_platform_callback, hass, config_entry, login, callback_data
        )

    configurator = hass.components.configurator
    status = login.status
    email = login.email
    # links = ""
    footer = ""
    config_id = None
    if "error_message" in status and status["error_message"]:
        footer = (
            "\n<b>NOTE: Actual Amazon error message in red below. "
            "Remember password will be provided automatically"
            " and Amazon error message normally appears first!</b>"
        )
    # if login.links:
    #     links = '\n\nGo to link with link# (e.g. link0)\n' + login.links
    # Get Captcha
    if (
        status
        and "captcha_image_url" in status
        and status["captcha_image_url"] is not None
    ):
        config_id = configurator.async_request_config(
            "Alexa Media Player - Captcha - {}".format(email),
            configuration_callback,
            description=(
                "Please enter the text for the captcha."
                " Please hit confirm to reload image." + footer
                # + links
            ),
            description_image=status["captcha_image_url"],
            submit_caption="Confirm",
            fields=[{"id": "captcha", "name": "Captcha"}],
        )
    elif (
        status and "securitycode_required" in status and status["securitycode_required"]
    ):  # Get 2FA code
        config_id = configurator.async_request_config(
            "Alexa Media Player - 2FA - {}".format(email),
            configuration_callback,
            description=(
                "Please enter your Two-Factor Security code."
                # + links
                + footer
            ),
            submit_caption="Confirm",
            fields=[{"id": "securitycode", "name": "Security Code"}],
        )
    elif (
        status and "claimspicker_required" in status and status["claimspicker_required"]
    ):  # Get picker method
        options = status["claimspicker_message"]
        if options:
            config_id = configurator.async_request_config(
                "Alexa Media Player - Verification Method - {}".format(email),
                configuration_callback,
                description=(
                    "Please select the verification method by number. "
                    "(e.g., `0` or `1`).\n{}".format(options)
                    # + links
                    + footer
                ),
                submit_caption="Confirm",
                fields=[{"id": "claimsoption", "name": "Option"}],
            )
        else:
            await configuration_callback({})
    elif (
        status and "authselect_required" in status and status["authselect_required"]
    ):  # Get picker method
        options = status["authselect_message"]
        if options:
            config_id = configurator.async_request_config(
                "Alexa Media Player - OTP Method - {}".format(email),
                configuration_callback,
                description=(
                    "Please select the OTP method by number. "
                    "(e.g., `0`, `1`).<br />{}".format(options)
                    # + links
                    + footer
                ),
                submit_caption="Confirm",
                fields=[{"id": "authselectoption", "name": "Option"}],
            )
        else:
            await configuration_callback({})
    elif (
        status
        and "verificationcode_required" in status
        and status["verificationcode_required"]
    ):  # Get picker method
        config_id = configurator.async_request_config(
            "Alexa Media Player - Verification Code - {}".format(email),
            configuration_callback,
            description=(
                "Please enter received verification code."
                # + links
                + footer
            ),
            submit_caption="Confirm",
            fields=[{"id": "verificationcode", "name": "Verification Code"}],
        )
    else:  # Check login
        config_id = configurator.async_request_config(
            "Alexa Media Player - Begin - {}".format(email),
            configuration_callback,
            description=("Please hit confirm to begin login attempt."),
            submit_caption="Confirm",
            fields=[],
        )
    if config_id:
        hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"].append(config_id)
    if "error_message" in status and status["error_message"]:
        configurator.async_notify_errors(config_id, status["error_message"])
    if len(hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"]) > 1:
        configurator.async_request_done(
            (hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"]).pop(0)
        )


# Traceback (alexapy.aiohttp.client_exceptions.InvalidURL)
2020-06-25 09:58:43 DEBUG (MainThread) [custom_components.alexa_media.configurator] Configurator closed for Status: {'login_failed': True}
got captcha: yb2xdb securitycode: None Claimsoption: None AuthSelectOption: None  VerificationCode: None
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] No valid cookies for log in; using credentials
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Loaded last request to https://www.amazon.com/ap/cvf/approval?arb=af57af10-eaf2-4d11-9571-b2638e527364&amp;openid.assoc_handle=amzn_dp_project_dee&amp;pageId=amzn_dp_project_dee&amp;openid.return_to=https://www.amazon.com/ap/signin?ie%3DUTF8%26clientContext%3D134-9998583-4128222%26arb%3Dc99ef662-1cf9-4f7b-943c-c2a9da4f2ecd%26showRmrMe%3D1%26use_global_authentication%3Dfalse%26openid.return_to%3Dhttps%253A%252F%252Falexa.amazon.com%252F%26openid.identity%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26openid.assoc_handle%3Damzn_dp_project_dee%26openid.mode%3Dcheckid_setup%26use_audio_captcha%3Dfalse%26pageId%3Damzn_dp_project_dee%26openid.claimed_id%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26openid.ns%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Processing https://www.amazon.com/ap/cvf/approval?arb=af57af10-eaf2-4d11-9571-b2638e527364&amp;openid.assoc_handle=amzn_dp_project_dee&amp;pageId=amzn_dp_project_dee&amp;openid.return_to=https://www.amazon.com/ap/signin?ie%3DUTF8%26clientContext%3D134-9998583-4128222%26arb%3Dc99ef662-1cf9-4f7b-943c-c2a9da4f2ecd%26showRmrMe%3D1%26use_global_authentication%3Dfalse%26openid.return_to%3Dhttps%253A%252F%252Falexa.amazon.com%252F%26openid.identity%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26openid.assoc_handle%3Damzn_dp_project_dee%26openid.mode%3Dcheckid_setup%26use_audio_captcha%3Dfalse%26pageId%3Damzn_dp_project_dee%26openid.claimed_id%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0%252Fidentifier_select%26openid.ns%3Dhttp%253A%252F%252Fspecs.openid.net%252Fauth%252F2.0
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Links: {'0': ('Customer Service', 'https://alexa.amazon.com/gp/help/customer/account-issues/ref=ch_tiv_approval_broadcast_contact_cs?ie=UTF8'), '1': ('Conditions of Use', 'https://alexa.amazon.com/gp/help/customer/display.html/ref=ap_desktop_footer_cou?ie=UTF8&amp;nodeId=508088'), '2': ('Privacy Notice', 'https://alexa.amazon.com/gp/help/customer/display.html/ref=ap_desktop_footer_privacy_notice?ie=UTF8&amp;nodeId=468496'), '3': ('Help', 'https://alexa.amazon.com/help')}
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Captcha/2FA not requested; confirming login.
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Testing whether logged in to alexa.amazon.com
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Cookies: None
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
amazon.com: expires:Fri, 25-Jun-2021 13:55:40 GMT max-age: session-id=140-1926401-1030615
amazon.com: expires:Fri, 25-Jun-2021 13:55:40 GMT max-age: session-id-time=2223813340l
amazon.com: expires:Fri, 25-Jun-2021 13:55:40 GMT max-age: ubid-main=134-9998583-4128222
amazon.com: expires:Fri, 25-Jun-2021 13:55:40 GMT max-age: session-token=8h23vDpL3moF2+OoX4OrRPk9rK0ccWd6ey1Ux+oQrPU4zSZ8OQOWY/jENsKLBLt3Hg5fObX6bsDPSXfZJuT6zS+FejQBWYbVC+lBM7hLv802EznMWudO75Ahi9v54fX3e61AZX6aYMD4lJS7S4OPf/j6nwwZyti2MevSmab7WJcNHEPS3++E4GaUutgiYYfP2iim9LhRfDq25seyiPmO55MrVBsvcR02

2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Header: {"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", "Accept": "text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "*", "Referer": "https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https://alexa.amazon.com/api/bootstrap&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.ns=http://specs.openid.net/auth/2.0&amp;"}
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] GET: redirected from
https://alexa.amazon.com/api/bootstrap
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] GET:
https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https://alexa.amazon.com/api/bootstrap&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.ns=http://specs.openid.net/auth/2.0&amp; with
<CIMultiDictProxy('Host': 'www.amazon.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Accept-Encoding': 'gzip, deflate', 'Cookie': 'session-id=140-1926401-1030615; session-id-time=2223813340l; session-token=8h23vDpL3moF2+OoX4OrRPk9rK0ccWd6ey1Ux+oQrPU4zSZ8OQOWY/jENsKLBLt3Hg5fObX6bsDPSXfZJuT6zS+FejQBWYbVC+lBM7hLv802EznMWudO75Ahi9v54fX3e61AZX6aYMD4lJS7S4OPf/j6nwwZyti2MevSmab7WJcNHEPS3++E4GaUutgiYYfP2iim9LhRfDq25seyiPmO55MrVBsvcR02; ubid-main=134-9998583-4128222')>
returned 200:OK with response <CIMultiDictProxy('Content-Type': 'text/html;charset=UTF-8', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Thu, 25 Jun 2020 13:58:43 GMT', 'Strict-Transport-Security': 'max-age=47474747; includeSubDomains; preload', 'X-XSS-Protection': '1', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'x-ua-compatible': 'IE=edge', 'Pragma': 'No-cache', 'Cache-Control': 'max-age=0, no-cache, no-store, must-revalidate', 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT', 'Set-Cookie': 'ap-fid=""; Domain=.amazon.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/ap/; Secure', 'Set-Cookie': 'session-id=140-1926401-1030615; Domain=.amazon.com; Expires=Fri, 25-Jun-2021 13:58:43 GMT; Path=/; Secure', 'Set-Cookie': 'session-id-time=2223813523l; Domain=.amazon.com; Expires=Fri, 25-Jun-2021 13:58:43 GMT; Path=/; Secure', 'Set-Cookie': 'ubid-main=134-9998583-4128222; Domain=.amazon.com; Expires=Fri, 25-Jun-2021 13:58:43 GMT; Path=/; Secure', 'Set-Cookie': 'session-token=8h23vDpL3moF2+OoX4OrRPk9rK0ccWd6ey1Ux+oQrPU4zSZ8OQOWY/jENsKLBLt3Hg5fObX6bsDPSXfZJuT6zS+FejQBWYbVC+lBM7hLv802EznMWudO75Ahi9v54fX3e61AZX6aYMD4lJS7S4OPf/j6nwwZyti2MevSmab7WJcNHEPS3++E4GaUutgiYYfP2iim9LhRfDq25seyiPmO55MrVBsvcR02; Domain=.amazon.com; Expires=Fri, 25-Jun-2021 13:58:43 GMT; Path=/; Secure', 'Vary': 'Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent', 'Content-Encoding': 'gzip', 'x-amz-rid': 'JMCCBZ7J4HJ1WGY691Y4', 'p3p': 'policyref="http://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 47f167ca4b48d927b2e7abade7ebfcfd.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'EWR53-C2', 'X-Amz-Cf-Id': 'NKVTOa0BA2jOQREwCZNigAr-4RuO3sVBqrwzwxJA08I2QWajydazHg==')>
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Not logged in: An exception of type ContentTypeError occurred. Arguments:
(RequestInfo(url=URL('https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https://alexa.amazon.com/api/bootstrap&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.ns=http://specs.openid.net/auth/2.0&amp;'), method='GET', headers=<CIMultiDictProxy('Host': 'www.amazon.com', 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36', 'Accept': 'text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8', 'Accept-Language': '*', 'Accept-Encoding': 'gzip, deflate', 'Cookie': 'session-id=140-1926401-1030615; session-id-time=2223813340l; session-token=8h23vDpL3moF2+OoX4OrRPk9rK0ccWd6ey1Ux+oQrPU4zSZ8OQOWY/jENsKLBLt3Hg5fObX6bsDPSXfZJuT6zS+FejQBWYbVC+lBM7hLv802EznMWudO75Ahi9v54fX3e61AZX6aYMD4lJS7S4OPf/j6nwwZyti2MevSmab7WJcNHEPS3++E4GaUutgiYYfP2iim9LhRfDq25seyiPmO55MrVBsvcR02; ubid-main=134-9998583-4128222')>, real_url=URL('https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https://alexa.amazon.com/api/bootstrap&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.ns=http://specs.openid.net/auth/2.0&amp;')), (<ClientResponse(https://alexa.amazon.com/api/bootstrap) [302 Found]>
<CIMultiDictProxy('Content-Length': '20', 'Connection': 'keep-alive', 'Server': 'Server', 'Date': 'Thu, 25 Jun 2020 13:58:43 GMT', 'x-amzn-RequestId': 'f4dfb93c-5c54-4c10-b4d2-0486b2c7fb6b', 'Content-Encoding': 'gzip', 'Location': 'https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https%3A%2F%2Falexa.amazon.com%2Fapi%2Fbootstrap&amp;openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&amp;', 'Vary': 'Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent', 'x-amz-rid': 'Q8EKT8H5R6HCHYXRHJSK', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 42d3518040c55e24793897f7f5d5f342.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'EWR53-C1', 'X-Amz-Cf-Id': 'fT36v385S1gzLfpImmB0gX1kumcRGSVxKu4arqMHVaZT0fKtQW2uMQ==')>
,))
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Login failed; check credentials
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] If credentials correct, please report these missing values: ['encryptedPasswordExpected']
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Found form to process: <form action="/ap/cvf/approval/poll" id="pollingForm" method="get">
<input name="arb" type="hidden" value="af57af10-eaf2-4d11-9571-b2638e527364"/><input name="openid.return_to" type="hidden" value="https://www.amazon.com/ap/signin?ie=UTF8&amp;amp;clientContext=134-9998583-4128222&amp;amp;arb=c99ef662-1cf9-4f7b-943c-c2a9da4f2ecd&amp;amp;showRmrMe=1&amp;amp;use_global_authentication=false&amp;amp;openid.return_to=https%3A%2F%2Falexa.amazon.com%2F&amp;amp;openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;amp;openid.assoc_handle=amzn_dp_project_dee&amp;amp;openid.mode=checkid_setup&amp;amp;use_audio_captcha=false&amp;amp;pageId=amzn_dp_project_dee&amp;amp;openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&amp;amp;openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0"/><input name="pageId" type="hidden" value="amzn_dp_project_dee"/><input name="openid.assoc_handle" type="hidden" value="amzn_dp_project_dee"/>
<input name="csrfToken" type="hidden" value="WelHiwUgMyLoYiae5OGOj2B5nklfMj3D"/></form>
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Found post url to /ap/cvf/approval/poll
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Preparing post to /ap/cvf/approval/poll with input data: {'captcha': 'yb2xdb'}
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] WARNING: Detected missing params: True
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Session Cookies:
amazon.com: expires:Fri, 25-Jun-2021 13:58:43 GMT max-age: session-id=140-1926401-1030615
amazon.com: expires:Fri, 25-Jun-2021 13:58:43 GMT max-age: session-id-time=2223813523l
amazon.com: expires:Fri, 25-Jun-2021 13:58:43 GMT max-age: ubid-main=134-9998583-4128222
amazon.com: expires:Fri, 25-Jun-2021 13:58:43 GMT max-age: session-token=8h23vDpL3moF2+OoX4OrRPk9rK0ccWd6ey1Ux+oQrPU4zSZ8OQOWY/jENsKLBLt3Hg5fObX6bsDPSXfZJuT6zS+FejQBWYbVC+lBM7hLv802EznMWudO75Ahi9v54fX3e61AZX6aYMD4lJS7S4OPf/j6nwwZyti2MevSmab7WJcNHEPS3++E4GaUutgiYYfP2iim9LhRfDq25seyiPmO55MrVBsvcR02

2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Submit Form Data: {"appActionToken": "j2FOkmfmlIlOKBVl5Uj2BesgXomez1cj3D", "appAction": "SIGNIN", "ces": "ape:QUNTXzVQbU9XL1VhOGpSWGtXNFlUaW0rcm45L2YzOEFBQUFBQUFBQUFXQ0k4d3k1MnZxM3I5dG1BWFZNVENLSlZ3YTFuNUxqdnkvWVROb1h6TzVlMnVHS0ZLa1FCZmdBV1dUYWpTSmxlQmlzcTJiQUFLNzlZZEZSNjBaWERBRklOcWt4UGpXOFFHaC9FVU1xcWRXV1RJa0QzRUpQVkZTWjZBQzFSaWRScXhEbVZNbktuWjFocjJzUENVKzZRSHcwWndPN1h6alRVUGlxWWZFU29ZUEJ3RDZsQklld2V6VGFPdHl3T2h0NTl4ZnhzRHJhUXhzNmNaenZRZFFpWmZ5NElrN3FqNStnNjhPNnVSeFJYc3ZtZSs5S1FqSWZmQXZmUGZSNUNjd0N1ZWw2R1Rsbm4zNEFaSEJrSDJJNFhuVUdTYmRaU3lwMlNuTXVzeHpTOWhxVmZjbHhIdkp2VWxXWDl2Mzl5QzFLZ2hXN2d0ZkNMMVFMdWNjQmVTVnpGSjA9", "openid.return_to": "ape:aHR0cHM6Ly9hbGV4YS5hbWF6b24uY29tLw==", "prevRID": "ape:UE1SREpITldBRFBFQUZCQjVIMFA=", "workflowState": "eyJ6aXAiOiJERUYiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiQTI1NktXIn0.P1GiCr5aRGE08ZXGE5IQnjF-CmoCP-I7MCJBoQhnJvd5fj42gl7gVQ.FAArKRJEeEZBWT0F.wlI60VN6NVU-UDBa0tbYV8E8Q1is3QR5fZeYMGXtv-pik0JvMzBPVISKsX7YwRaGrYeAjrU6IcB-o9BOYpGWA99Txw3lQyxA4NPa5aOe9QjVclwm231CUyXp60J7CVqXEJXuxp5PrbfUBKtz9qq3bcR1u7OUDmOr54SR4vai9_Mckd-KpL7OO5V1up7o4VDANLGpvuYvq7HuAXWa-z-27yP8F97hb3Fx-xkwpTU-6uzSnbqXJ1llKx2t2CZmUnxDy01ZxK2uMhmJM_xFQWyc1qpASM3ZzWb1XjW9BzgZ6do8jw49f90VcLxFcMmB2PgMYTj8_7f2zlLkCPsrEecsIT8eh7sRCV3BOttqKIU4JurQ0j9CLG7xkWDHgzLzETuZHi3TvsLm-NsKRcOohC8ibns2ksaoo46ExUNjunoc8nYaCmq6wJjJy2HtnBARRcv9IqoziMiZzeCoM4ZuSH8Ap5uudh1XutZm4iZpzfMTKbARJaPYBkWQnJcaT8x8rFRklIBYFD6rVsGhcN2QH-V_Sw102ymM5ZJLROw17nM.V0hq9Zzfm8kuumYCAgMdzg", "email":": "false", "encryptedPasswordExpected": "", "rememberMe": "true", "use_image_captcha": "true", "use_audio_captcha": "false", "guess": "yb2xdb"}
2020-06-25 09:58:43 DEBUG (MainThread) [alexapy.alexalogin] Header: {"User-Agent": "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36", "Accept": "text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8", "Accept-Language": "*", "Referer": "https://www.amazon.com/ap/signin?showRmrMe=1&amp;openid.return_to=https://alexa.amazon.com/api/bootstrap&amp;openid.identity=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.assoc_handle=amzn_dp_project_dee&amp;openid.mode=checkid_setup&amp;openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&amp;openid.ns=http://specs.openid.net/auth/2.0&amp;"}
2020-06-25 09:58:43 ERROR (MainThread) [alexapy.helpers] alexalogin.login((<alexapy.alexalogin.AlexaLogin object at 0x7f8cddc52890>,), {'data': {'captcha': 'yb2xdb'}}): An error occured accessing AlexaAPI: An exception of type InvalidURL occurred. Arguments:
(URL('/ap/cvf/approval/poll'),)
2020-06-25 09:58:43 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140242973399952] /ap/cvf/approval/poll
Traceback (most recent call last):
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
connection.context(msg),
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1260, in async_call
task.result()
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/core.py", line 1295, in _execute_service
await handler.func(service_call)
File "/srv/homeassistant/lib/python3.7/site-packages/homeassistant/components/configurator/__init__.py", line 235, in async_handle_service_call
await self.hass.async_add_job(callback, call.data.get(ATTR_FIELDS, {}))
File "/home/homeassistant/.homeassistant/custom_components/alexa_media/configurator.py", line 28, in configuration_callback
setup_platform_callback, hass, config_entry, login, callback_data
File "/home/homeassistant/.homeassistant/custom_components/alexa_media/configurator.py", line 177, in setup_platform_callback
await login.login(data=callback_data)
File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/helpers.py", line 104, in wrapper
return await func(*args, **kwargs)
File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/alexalogin.py", line 431, in login
site, data=self._data, headers=self._headers, ssl=self._ssl,
File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client.py", line 506, in _request
traces=traces,
File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client_reqrep.py", line 308, in __init__
self.update_host(url)
File "/srv/homeassistant/lib/python3.7/site-packages/alexapy/aiohttp/client_reqrep.py", line 369, in update_host
raise InvalidURL(url)
alexapy.aiohttp.client_exceptions.InvalidURL: /ap/cvf/approval/poll`

# Fixed code
async def request_configuration(hass, config_entry, login):
    """Request configuration steps from the user using the configurator."""

    async def configuration_callback(callback_data):
        """Handle the submitted configuration."""
        await hass.async_add_job(
            setup_platform_callback, hass, config_entry, login, callback_data
        )

    configurator = hass.components.configurator
    status = login.status
    email = login.email
    # links = ""
    footer = ""
    config_id = None
    if status and status.get("error_message"):
        footer = (
            "\n<b>NOTE: Actual Amazon error message in red below. "
            "Remember password will be provided automatically"
            " and Amazon error message normally appears first!</b>"
        )
    # if login.links:
    #     links = '\n\nGo to link with link# (e.g. link0)\n' + login.links
    # Get Captcha
    if status and status.get("captcha_image_url"):
        _LOGGER.debug("Creating configurator to request captcha")
        config_id = configurator.async_request_config(
            f"Alexa Media Player - Captcha - {email}",
            configuration_callback,
            description=(
                "Please enter the text for the captcha."
                " Please enter anything to reload image." + footer
                # + links
            ),
            description_image=status["captcha_image_url"],
            submit_caption="Confirm",
            fields=[{"id": "captcha", "name": "Captcha"}],
        )
    elif status and status.get("securitycode_required"):  # Get 2FA code
        _LOGGER.debug("Creating configurator to request 2FA")
        config_id = configurator.async_request_config(
            f"Alexa Media Player - 2FA - {email}",
            configuration_callback,
            description=(
                "Please enter your Two-Factor Security code."
                # + links
                + footer
            ),
            submit_caption="Confirm",
            fields=[{"id": "securitycode", "name": "Security Code"}],
        )
    elif status and status.get("claimspicker_required"):  # Get picker method
        _LOGGER.debug("Creating configurator to select verification option")
        options = status["claimspicker_message"]
        if options:
            config_id = configurator.async_request_config(
                f"Alexa Media Player - Verification Method - {email}",
                configuration_callback,
                description=(
                    "Please select the verification method by number. "
                    "(e.g., `0` or `1`).\n{}".format(options)
                    # + links
                    + footer
                ),
                submit_caption="Confirm",
                fields=[{"id": "claimsoption", "name": "Option"}],
            )
        else:
            await configuration_callback({})
    elif status and status.get("authselect_required"):  # Get picker method
        _LOGGER.debug("Creating configurator to select OTA option")
        options = status["authselect_message"]
        if options:
            config_id = configurator.async_request_config(
                f"Alexa Media Player - OTP Method - {email}",
                configuration_callback,
                description=(
                    "Please select the OTP method by number. "
                    "(e.g., `0`, `1`).<br />{}".format(options)
                    # + links
                    + footer
                ),
                submit_caption="Confirm",
                fields=[{"id": "authselectoption", "name": "Option"}],
            )
        else:
            await configuration_callback({})
    elif status and status.get("verificationcode_required"):  # Get picker method
        _LOGGER.debug("Creating configurator to enter verification code")
        config_id = configurator.async_request_config(
            f"Alexa Media Player - Verification Code - {email}",
            configuration_callback,
            description=(
                "Please enter received verification code."
                # + links
                + footer
            ),
            submit_caption="Confirm",
            fields=[{"id": "verificationcode", "name": "Verification Code"}],
        )
    elif status and status.get("force_get"):  # Javascript authentication check
        _LOGGER.debug("Creating configurator to wait for user action")
        config_id = configurator.async_request_config(
            f"Alexa Media Player - Action Required - {email}",
            configuration_callback,
            description=(
                "Amazon will send a push notification per the below message."
                " Please completely respond before continuing." + footer
                # + links
            ),
            submit_caption="Confirm",
            fields=[],
        )
    else:  # Check login
        _LOGGER.debug("Creating configurator to start new login attempt")
        config_id = configurator.async_request_config(
            f"Alexa Media Player - Begin - {email}",
            configuration_callback,
            description=("Please hit confirm to begin login attempt."),
            submit_caption="Confirm",
            fields=[],
        )
    if config_id:
        hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"].append(config_id)
    if status.get("error_message"):
        configurator.async_notify_errors(config_id, status["error_message"])
    if status.get("message"):
        configurator.async_notify_errors(config_id, status["message"])
    if len(hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"]) > 1:
        configurator.async_request_done(
            (hass.data[DATA_ALEXAMEDIA]["accounts"][email]["configurator"]).pop(0)
        )