simbaja / gehome

Python SDK for GE smart appliances
MIT License
42 stars 29 forks source link

Could not obtain authorization code Error #62

Closed agentcipher closed 8 months ago

agentcipher commented 9 months ago

Trying to use the home assistant plugin and receiving the error below about not being able to obain an authorization code. It appears to be returning an HTML page as opposed to providing valid Oauth login information. The username/password information are able to login using the SmartHQ app and the password does not contain any special characters, only letters and numbers.

$ gehome-appliance-data -u my_username -p my_password -r US `Using slower stringprep, consider compiling the faster cython/libidn one. 2023-12-08 04:10:58,147 DEBUG Using selector: EpollSelector 2023-12-08 04:10:58,148 DEBUG Getting OAuth2 token 2023-12-08 04:10:58,148 DEBUG received event: state_changed, processing callbacks... 2023-12-08 04:10:58,148 DEBUG processing callback: <bound method GeBaseClient._on_state_change of <gehomesdk.clients.websocket_client.GeWebsocketClient object at 0x7f9e9a109490>> 2023-12-08 04:10:58,167 DEBUG Client changed state: GeClientState.INITIALIZING to GeClientState.AUTHORIZING_OAUTH 2023-12-08 04:10:59,422 ERROR There was a problem getting the authorization code, response details: {'method': 'POST', 'cookies': , '_real_url': URL('https://accounts.brillion.geappliances.com/oauth2/g_authenticate'), '_url': URL('https://accounts.brillion.geappliances.com/oauth2/g_authenticate'), '_body': b'\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n<!DOCTYPE html>\n\n\n OAuth Login\n\n\n\n\n\t\n\t\n\n\n\n\n\n<link\n\thref="/resources/scripts/css/bootstrap.min.css"\n\trel="stylesheet" />\n<link\n\thref="/resources/scripts/css/desktop.css"\n\trel="stylesheet" />\n\n\t<link href="https://fonts.googleapis.com/css?family=Poppins:400,500,600,700,900&display=swap"\n \trel="stylesheet">\n<script\n\tsrc="/resources/scripts/jquery-3.5.1.min.js">\n\n\n\n\n\n\n\n\n \n

\n
\n \n \t\t \n\n\n\n\n\n\n\n\n\t
\n\t
\n\t \n\t
\n\t
\n\t
\n
\n \n

Sign In

\n \n One account across our brands.
\n \n
\n\n\n
\n\n\n\n\n
\n\t\n\t\t
\n\t\t\t\t<input type="hidden" id="client_id" value="564c31616c4f7474434b307435412b4d2f6e7672"\n\t\t\t\t\tname="client_id" />\n\t\t\t\t<input type="hidden" id="response_type" value="code"\n\t\t\t\t\tname="response_type" />\n\t\t\t\t<input type="hidden" id="access_type" value="offline"\n\t\t\t\t\tid="access_type" />\n\t\t
\n\t\t
\n\t\t\t
\n\t\t\t\t<input type="hidden" id="signature" name="signature"\n\t\t\t\t\tvalue="vVLoPdzS242Elr8Q7VEjLwtnFvSSY62MrSVnFTi69BfzV92DD8TQbdXqL8kKA5+JwdqYrppWFC6Np7APE6ubH3imNW7+CyPuI9P4fMLssZsSUJVNH3ATRpqxPhT+MBNGeFhaKIpBjFl3xD/mFzwe1BxwIUvVmyUpiy09qr/2Z4Arp8aWdGsMYy030Xs3EvnCERX2sP4byYqXYZCb5DPjBUwnFREnouETJBeTIOYf1SJlZbjd1vbDl3poynR7l/tsSyX70yz7E2SK/IeI3mEIjtcrlKSn8beo8Tvs+UY1/dnnGE0DCWYvm94E9J4JXTr3l7Zm7FVgD42iwJryItzrzfkk03x504Fn6CJpyAt+9L39JmZbJqiC0xqP+9+4jDqP39ZK9TNHbyM8bc0tmj5InMR71dpjs0DUBWEB82QjieV5TnHe0N0zNf0oA55R0/EDEtCWds1hhuYAzuWd3FUGP6GeED8ISvLYhXF2EspXTDrGNvIG8ct7XyvCHTs2WZNLPRfPwdpQz2roT7wCiY5VRQEwE6Jpj2Iq0LwaEJN6O0EmVCUHJ8gsrWiGNhUUEqgSeUfzyrP4zNPeEf828zzeXRUHHz4qbJNJqSka/243CMxQGhLp+PVsFR2IvTEkePoUre9fX4GaCZzwziFrrt8r3p3a8hhoXeELMQKVH+wdIu4/xtvBj1l4ITQ9DZ4JymzcAXt9q9xQQbsQCLCDS/WVL9qlJk4xu6laRTLuRBy0L8/HLN6nvHMgIK7JF2mUc9GiXm61uSzOgceTe8JMtHR4MwhaF7n5SPNBMzDZrmgEC5sABEGaMufbWfVxgXFbj7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zjFE4dSJxCL+CPK+XgeTACpiuyzhYHNWHOBstPvv8j+vGGWktQifXXspzT2S2lpDwKrRFt0lHXGCnxHdoiZSuGCPL2j7TmOBvxaiAFuDS7gWwUCmuhqoIQ0iyTQNhqs4tkP91/jOPy+d+uMXf/MF/ef4Ue/m0/FtrZXdSitphZ9RVVnpmqgL5IDz76EsrVah88C+0xRCTr76BlGswa59azeBRCZ9HZh/6BqOkEQID2ciAWaCxYqCXUiNci/c+/p57d096qW1iGN65XeopXgRqbdP2d2wxmq0nDHYEPylI38SYXUwOO2huF6ZJ95u8wau7GZFAcYp0rW9DIZ3yQu/UYXt9WrGASOAVNSfk5mnL4aEKZBx7hIgRYuBWeNmOhBMgSPEg3N7LpKfnNebW5VEcApm1D3JESYKToxw==" />\n\t\t\t
\n\t\t\t
\n\t\t\t\t<input type="email" class="form-control" id="username"\n\t\t\t\t\tname="username" placeholder="Username" autocapitalize="off"\n\t\t\t\t\tvalue="my_username" tabindex="1" />\n\t\t\t\t
\n\t\t\t
\n\t\t\t
\n\t\t\t\t<input type="password" class="form-control" id="password"\n\t\t\t\t\tname="password" placeholder="Password" tabindex="2" maxlength="20" />\n\t\t\t\t Show Password
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t
\n\t\t\t<button type="button" id="signin_btn" name="signin_btn" class="btn_signIn btn btn-default btn-primary"\n\t\t\t\tonClick="javascript:oauthLogin()" tabindex="4">\n\t\t\t\t\tSIGN IN\n\t\t\t\t\n\t\t\t
\n\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t\t\t\tIf you have a European or United Kingdom account,\n\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\tsign in here\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t
\n\n\t\t\t\t\t
\n\t\t\t
\n\n\t\t\t
\n
\n
\n
\n\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t\t\t\t\t
Don\'t have an account? Sign up here
\n\n\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t
\n\t\t\t\n\t\t
\n
\n\n\n\n\n\n\n\n\n\n\n\t\n\n\n
\n\t\t
\n\t
\n\n\t\n \t
\n \t
\n
\n
\n
\n

\n Copyright 2020 GE Appliances, a Haier company GE is trademark of General Electric Company.Manufactured under trademark license.\n

\n
\n
\n
\n
\n \t \n\t
\n\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n<script\r\n\tsrc="/resources/scripts/js/bootstrap.min.js">\r\n<script\r\n\tsrc="/resources/scripts/js/bootstrap-show-password.min.js">\r\n<script\r\n\tsrc="/resources/scripts/common.js">\r\n\r\n\r\n\r\n\r\n\n\n', '_writer': None, '_continue': None, '_closed': True, '_history': (), '_request_info': RequestInfo(url=URL('https://accounts.brillion.geappliances.com/oauth2/g_authenticate'), method='POST', headers=<CIMultiDictProxy('Host': 'accounts.brillion.geappliances.com', 'Accept': '/', 'Accept-Encoding': 'gzip, deflate', 'User-Agent': 'Python/3.11 aiohttp/3.8.5', 'Cookie': 'JSESSIONID=64DDC436124E8D9E0EF2E50693432133; abgea_region=us-east-1', 'Content-Length': '2615', 'Content-Type': 'application/x-www-form-urlencoded')>, real_url=URL('https://accounts.brillion.geappliances.com/oauth2/g_authenticate')), '_timer': <aiohttp.helpers.TimerContext object at 0x7f9e9a11f850>, '_cache': {'headers': <CIMultiDictProxy('Content-Type': 'text/html;charset=ISO-8859-1', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Fri, 08 Dec 2023 04:10:59 GMT', 'X-Amzn-Trace-Id': 'Root=1-65729752-5f8b75295d889aa330bb0b87;', 'Set-Cookie': 'abgea_region=us-east-1; Path=/; Secure; HttpOnly', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 d775d0025d4d26af03f89c82cea6813e.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'ATL58-P4', 'X-Amz-Cf-Id': '9MAp66YCJrrJPd157ejawBvAGZ_u-nhpzPr9PCM2MjcFqwN1Bjzt1w==')>, 'url': URL('https://accounts.brillion.geappliances.com/oauth2/g_authenticate')}, '_traces': [], '_loop': <_UnixSelectorEventLoop running=True closed=False debug=False>, '_session': None, '_protocol': <aiohttp.client_proto.ResponseHandler object at 0x7f9e9a0e25f0>, '_connection': None, 'version': HttpVersion(major=1, minor=1), 'status': 200, 'reason': '', '_headers': <CIMultiDictProxy('Content-Type': 'text/html;charset=ISO-8859-1', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Date': 'Fri, 08 Dec 2023 04:10:59 GMT', 'X-Amzn-Trace-Id': 'Root=1-65729752-5f8b75295d889aa330bb0b87;', 'Set-Cookie': 'abgea_region=us-east-1; Path=/; Secure; HttpOnly', 'X-Frame-Options': 'DENY', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'Cache-Control': 'no-cache, no-store, max-age=0, must-revalidate', 'Pragma': 'no-cache', 'Expires': '0', 'X-Cache': 'Miss from cloudfront', 'Via': '1.1 d775d0025d4d26af03f89c82cea6813e.cloudfront.net (CloudFront)', 'X-Amz-Cf-Pop': 'ATL58-P4', 'X-Amz-Cf-Id': '9MAp66YCJrrJPd157ejawBvAGZ_u-nhpzPr9PCM2MjcFqwN1Bjzt1w==')>, '_raw_headers': ((b'Content-Type', b'text/html;charset=ISO-8859-1'), (b'Transfer-Encoding', b'chunked'), (b'Connection', b'keep-alive'), (b'Date', b'Fri, 08 Dec 2023 04:10:59 GMT'), (b'X-Amzn-Trace-Id', b'Root=1-65729752-5f8b75295d889aa330bb0b87;'), (b'Set-Cookie', b'abgea_region=us-east-1; Path=/; Secure; HttpOnly'), (b'X-Frame-Options', b'DENY'), (b'X-Content-Type-Options', b'nosniff'), (b'X-XSS-Protection', b'1; mode=block'), (b'Cache-Control', b'no-cache, no-store, max-age=0, must-revalidate'), (b'Pragma', b'no-cache'), (b'Expires', b'0'), (b'X-Cache', b'Miss from cloudfront'), (b'Via', b'1.1 d775d0025d4d26af03f89c82cea6813e.cloudfront.net (CloudFront)'), (b'X-Amz-Cf-Pop', b'ATL58-P4'), (b'X-Amz-Cf-Id', b'9MAp66YCJrrJPd157ejawBvAGZ_u-nhpzPr9PCM2MjcFqwN1Bjzt1w==')), 'content': } Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 76, in async_get_authorization_code code = await async_handle_ok_response(session, await resp.text()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 111, in async_handle_ok_response raise GeAuthFailedError(f"Authentication failed, reason: {reason}") gehomesdk.exception.ge_auth_failed_error.GeAuthFailedError: Authentication failed, reason: Invalid Credentials 2023-12-08 04:10:59,423 ERROR Task exception was never retrieved future: <Task finished name='Task-1' coro=<GeBaseClient.async_get_credentials_and_run() done, defined at /usr/local/lib/python3.11/site-packages/gehomesdk/clients/base_client.py:117> exception=GeAuthFailedError('Could not obtain authorization code')> Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 76, in async_get_authorization_code code = await async_handle_ok_response(session, await resp.text()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 111, in async_handle_ok_response raise GeAuthFailedError(f"Authentication failed, reason: {reason}") gehomesdk.exception.ge_auth_failed_error.GeAuthFailedError: Authentication failed, reason: Invalid Credentials

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/base_client.py", line 119, in async_get_credentials_and_run await self.async_get_credentials(session) File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/base_client.py", line 191, in async_get_credentials await self.async_do_full_login_flow() File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/base_client.py", line 195, in async_do_full_login_flow self.credentials = await self._async_do_full_login_flow() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/websocket_client.py", line 63, in _async_do_full_login_flow await self._async_get_oauth2_token() File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/base_client.py", line 218, in _async_get_oauth2_token oauth_token = await async_get_oauth2_token( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 147, in async_get_oauth2_token code = await async_get_authorization_code(session, account_username, account_password, account_region) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/gehomesdk/clients/async_login_flows.py", line 83, in async_get_authorization_code raise GeAuthFailedError(f'Could not obtain authorization code') from exc gehomesdk.exception.ge_auth_failed_error.GeAuthFailedError: Could not obtain authorization code`

simbaja commented 9 months ago

Not sure why it wouldn't work, only things I can think of are the region is incorrect or you might need to enclose your username/password in single quotes?

agentcipher commented 8 months ago

To prevent future pain and suffering for someone else. The issue in this case appears to be that my password was too long🤦

simbaja commented 8 months ago

What is the max length, I can add that to the stickied posts?