Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Login from AU #12

Closed
cjsmns opened this issue Jan 30, 2022 · 5 comments · Fixed by #13 or #14
Closed

Login from AU #12

cjsmns opened this issue Jan 30, 2022 · 5 comments · Fixed by #13 or #14

Comments

@cjsmns
Copy link

cjsmns commented Jan 30, 2022

Version of the custom_component

Latest as of today

Configuration

Installed via HACS and configured via the devices page.

Describe the bug

I'm located in Australia and unable to login. It just says Unknown error occurred. I'm trying to login with NA. EU also says the same, but to also Please verify via myair2.resmed.com.

Originally posted this on the HA forums and directed to post a bug here.
https://community.home-assistant.io/t/resmed-cpap-sensor-integration-in-hacs/373367/19

HAR file sent via PM on HA forum.

Debug log

Logger: aiohttp.server
Source: custom_components/resmed_myair/client/new_client.py:236
Integration: ResMed myAir CPAP Sensors (documentation, issues)
First occurred: 1:30:09 PM (4 occurrences)
Last logged: 3:11:50 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/resmed_myair/config_flow.py", line 51, in async_step_user
    device: MyAirDevice = await get_device(
  File "/config/custom_components/resmed_myair/config_flow.py", line 31, in get_device
    device = await client.get_user_device_data()
  File "/config/custom_components/resmed_myair/client/new_client.py", line 236, in get_user_device_data
    device = records_json["data"]["getPatientWrapper"]["fgDevices"][0]
TypeError: 'NoneType' object is not subscriptable
prestomation added a commit that referenced this issue Jan 30, 2022
This seems to be validated by the graphql API. Validated using curl and ID tokens provided in a bug report from AU.

I've tested this in my test environemnt for US and added unit test

Should fix #12
@prestomation
Copy link
Owner

@cjsmns Thanks for the bug report! In the integration, "US" was hardcoded for a particular parameter when using myair2.resmed.com. Using your report I've found there is one particular piece that requires the correct country code.

Please update in HACS.to the newest version and let me know if it works or not. Please include the logs again if you continue having issues.

@cjsmns
Copy link
Author

cjsmns commented Jan 30, 2022

Still not working. New error log...

Logger: aiohttp.server
Source: custom_components/resmed_myair/client/new_client.py:152
Integration: ResMed myAir CPAP Sensors (documentation, issues)
First occurred: 8:02:43 PM (1 occurrences)
Last logged: 8:02:43 PM

Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_protocol.py", line 435, in _handle_request
    resp = await request_handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 60, in security_filter_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 98, in forwarded_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 78, in ban_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 181, in auth_middleware
    return await handler(request)
  File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 137, in handle
    result = await result
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 157, in post
    return await super().post(request, flow_id)
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 62, in wrapper
    result = await method(view, request, *args, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 110, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 252, in async_configure
    result = await self._async_handle_step(flow, cur_step["step_id"], user_input)
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 325, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
  File "/config/custom_components/resmed_myair/config_flow.py", line 51, in async_step_user
    device: MyAirDevice = await get_device(
  File "/config/custom_components/resmed_myair/config_flow.py", line 31, in get_device
    device = await client.get_user_device_data()
  File "/config/custom_components/resmed_myair/client/new_client.py", line 246, in get_user_device_data
    records_json = await self.gql_query("getPatientWrapper", query)
  File "/config/custom_components/resmed_myair/client/new_client.py", line 152, in gql_query
    decoded = base64.b64decode(self.id_token.split(".")[1])
  File "/usr/local/lib/python3.9/base64.py", line 87, in b64decode
    return binascii.a2b_base64(s)
binascii.Error: Incorrect padding

@prestomation
Copy link
Owner

Sorry about that. I've pushed another try at this fix. Let me know!

@cjsmns
Copy link
Author

cjsmns commented Jan 30, 2022

Yep. It's working now!!!

@prestomation
Copy link
Owner

Beautiful! Thanks for all the info to help make this integration better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants