-
Notifications
You must be signed in to change notification settings - Fork 29
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
New Single-Key Authentification #171
Comments
Sure! |
Cool. Lets hope someone picks up the challenge to look into the code. |
Capable? BS. I couldnt write a single code of Python a couple of years ago... |
I know that before people have used the Android app. The files are just zipped in an apl file. The Ios app is encrypted, the files cannot be reversed engineered. |
you need to reset the app - so clear the cache and data - it seems |
Fair enough, the mower does not need to be online though to test the login, this is purely authentication between HA (or the BoschSmartGarden app) and the backend. |
Force reset the app, and before logging in copy the link, paste it in postman Also, it seems that the home connect integration also works with that same ID website, maybe that's a way to go? |
@HAuser1234 before I login on the single key id login page, I launch the Developer tools / Network in chrome. Be careful that Authorization codes are very short-lived. Typically, they expire after about 10 minutes. So you need to use the code fast to succeed in step2 Did you manage to capture HTTP traffic from the actual indego app ? maybe it could help to understand what is missing to call the indego api. Clearly the bearer access token is not enough, maybe some sso cookies are also necessary. |
I was trying the same thing for hours... it seems there no need to call /authenticate after finishing the OAuth process! Just call the API you need info from with the Bearer header set :-) . My mower is still in winter storage. But this data seems to be correct... |
I'm wondering if some already started implementing the OAuth login in this HA plugin? I can do this, but I would like to know if someone already started to prevent us from developing the same thing ;-). Note that I have forked this project a few months ago to implement several small improvements. The most important one: Moved the configuration from yaml to GUI. I haven't yet opened a merge request as I wanted to test it myself after mower winter storage. Using this plugin config through the GUI would also make the OAuth flow more user friendly. |
Pull requests are welcome! |
I got the OAuth flow working in my dev environment, but there is a catch I would like to discuss first (before I fully implement it in the API calls)... Redirecting 'com.bosch.indegoconnect://login/?code=XXXXXXXX' to HomeAssistant was a hard one to solve. I have created a small Chrome extension to solve this issue which injects a redirect in the auth response. The user has to install this extension (temporary) before adding the component in HomeAssistant. I can't think of another cleaner way, except from Bosch allowing us to add custom client IDs like they did for the Home Connect API https://www.home-assistant.io/integrations/home_connect/ . But I couldn't find a Bosch developer portal for Indego. Is this acceptable? Or does someone have a better idea? |
Hello @sander1988, thanks for looking into this. Much appreciated! I'm surprised that it takes an extra browser plugin to authenticate, because OAuth and OpenID Connect are broadly adopted technologies. Many HA addons should have the same problem. Are you aware of HomeAssisants documentation on OAuth handling for integrations? In addition I found HA tipps for authentication but this looks like authentication against HA. So, I'd assume there is a better way than an extra Chrome plugin, but I did not try myself so I cannot tell exactly how. |
True, the HA API makes it easy to integrate OAuth ; that's I'm using. Normally it's not that difficult (this is not my first OAuth integration). But I think the challenge in this case it's clear enough. Let me explain...
|
Thanks, @sander1988. Your explanation makes the problem much clearer to me. The custom URL prefix is a common way to have a specific app reacting to a URL. The app simply registers itself as handler for the custom protocol and gets the request (callback) presented. Could we likewise register the Indego addon as custom protocol handler in HA? |
Yes and no. Yes if we write a fully custom OAuth helper for HA. No, when we use the build-in HA helper. Why? The OAuth helpers in HA work like this:
Point 1 is where we need to handle com.bosch.indegoconnect://login. I think I just came up with solution to work around this, but that takes much more development time to integrate. The idea: Develop a custom HA OAuth helper which proxies the auth flow web requests through HA (instead of directly in the browser) so we can replace/handle com.bosch.indegoconnect://login when it receives the redirect response. I'm pretty sure this will work, but I don't have the time to develop this at the moment. I'm to thinking of focussing on fixing the auth so we can use this component. And development a v2 of the auth which don't require the Chrome Extension when there is time. |
It works! I see data, but I can't test sending commands to the mower at the moment. I will do that within a few weeks when weather improves. I will monitor the integration for stability the next couple of weeks and create updates if an issue appears. I have created to merge requests: Please check first:
|
Congratulations @sander1988 this is quite impressive how you managed to support the new oauth flow ! The chrome extension is a great bypass. Let's hope Bosch will enable us to add custom client id and secret in the future. |
@sander1988 sorry for me bad english, i'm french ! thank you so much ! it's work for me ! |
I noticed that the client can get into a update state loop when the Bosch servers are down for some time (e.g. HTTP status 502). I had already tried to suppress such scenarios (https://github.com/sander1988/Indego/blob/master/custom_components/indego/__init__.py#L448) but it doesn't seem to be enough. @jm-73 - It there a reason why the client has been designed to suppress errors (return None) rather than raising them? This makes it harder to detect failure from the implementation side (in this case HA). |
@JeedHome44 - Do you mean the integer key of the mower state? https://github.com/jm-73/pyIndego/blob/ca6adbf8ac39875a32babaabef5011bfe6d40bfb/pyIndego/const.py#L92 E.g. 260 when the mower is charging? |
Hello! Yes please I need this information in number. Possible tu have a sensor with this in number ? Mower is ok but Alert is always true. |
Looking at the code this is true when there are more than 0 alerts in history. I have not changed this. In my opinion it should also check the read/unread status of the alert and only show 'Problem' in HA when there are unread alerts. Maybe open another issue when more people agree on this? So I expect that when you remove all alert messages (using the app) the state in HA resolves to OK after some time. |
I tested this - great work, thanks a lot for your work here! |
I agree! I have the latest version running now for 5 days without any issue. |
Merged today! |
But I cant get my installation to work... |
2023-04-26 22:32:57.099 INFO (MainThread) [custom_components.indego.config_flow] Successfully authenticated 2023-04-26 22:32:57.099 DEBUG (MainThread) [custom_components.indego.config_flow] Testing API access by retrieving available mowers... 2023-04-26 22:32:57.100 ERROR (MainThread) [aiohttp.server] Error handling request Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_app.py", line 504, in _handle
File "/usr/local/lib/python3.10/site-packages/aiohttp/web_middlewares.py", line 117, in impl
File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 100, in forwarded_middleware
File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 80, in ban_middleware
File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 235, in auth_middleware File "/usr/src/homeassistant/homeassistant/components/http/view.py", line 146, in handle
File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 171, in get
File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 96, in get
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 271, in async_configure
File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
File "/usr/src/homeassistant/homeassistant/helpers/config_entry_oauth2_flow.py", line 332, in async_step_creation
File "/config/custom_components/indego/config_flow.py", line 78, in async_oauth_create_entry
TypeError: IndegoAsyncClient.init() got an unexpected keyword argument 'token'` |
I would guess the pyIndego lib is not the new version that supports the new Single-Key auth. As 'token' is one of the new arguments. |
i have an issue too, everything is working fine as long as i don't restart my HA after adding the indego. if i restart HA i get the following log entry (also after multiple restarts): Error setting up entry Paula (128603577) for indego Do you have any idea what is wrong ? |
@kimzeuger - First make sure you are one the latest version with a fix for a similar issue (#173 (comment)). Also make sure your HA (or this integration) isn't offline for longer than 12 hours ; this is a limitation we can't fix and caused by a misconfiguration by Bosch (see #173 for more details) When it still happens please provide a few things:
Enable debug mode for these components:
Your OAuth state should look something like this:
|
@sander1988 - Thanks for your quick reply, seems as updating to the latest version fixed it. Sorry for disturbing, should have been able to manage this on my own. |
All, I have installed the latest version and now I am trying to enable the integration. After being redirected to the website, the website of Bosch first showed me the single-ID page, which I filled in. Thereafter it stays on a page that just says "Please wait" Any idea? |
Have you installed the Chrome extension? /Lars. |
@LarsLautrup, thanks for the quick reply! solved the issue (or actually not issue, just not reading properly) |
Hi, I'm sorry but I don't find the chrome extension for the login can anyone help ? |
https://github.com/sander1988/Indego/blob/master/chrome-extension.zip |
All, I got as far as the 'code' described in glppfr's post from Mar 7, but that's it. I'm not sure that the code (which is much longer than the "XXXXXXXX" shown in the Mar 8 post) is correct and what I must do with it. The rest of the messages in the thread don't make any sense to me and so I'm stuck. I'd be immensely grateful if someone more knowledgeable than me could assemble a set of steps that a novice could follow? |
please consider installing the chrome extension mentioned above. this made it easy to connect for me. |
Wow - how easy was that! So the 'novice' steps are...
And that's pretty much it - thanks again to all who made this possible. |
you can also download the fixed version with no manual file copying
Then you follow points 2, 4 and 5 from the above with no change:
|
@sander1988, thanks for this feature! @35aportal and @sytchi, thanks for the nice summary! Using the browser's developer tools (Firefox in my case) I was able to provide Home Assistant with the authentication reply without a browser plugin (although it requires minor manual work). When you get the
Just take the part beginning with the question mark (
The result should look something like this
and allows the authentication flow to finish. |
@codecat42 Many thanks! This is working like a charm. I made the mistake and replaced the domain When someone wants to use their own domain you can use the following url: |
I have successfuly managed to implement this integration to my Home Assistant. Many thanks to the developer. Are there only sensors in that Integration? I ready about something that in the current Version there should be a vaccum card available for Indego. But I have none? I created a Template Vaccum with Battery Level and Start/pause/Dock command but i'm not able to integrate States (in my language) as well? |
Is your response related to my question? - I have no issues with adding this Indego Integration to my HASS but i don't have to option to use Indego as a vacuum. I have manually addes a Template Vaccum with Mow/pause/dock but State is missing - i'm not able to realize the state of the Mower within this Template Vacuum. |
yes I‘m using the mushroom vacuum card and it seems to provide the state correctly - hope it helps. type: custom:mushroom-vacuum-card
entity: vacuum.indego
commands:
- on_off
- start_pause
- stop
- return_home
tap_action:
action: toggle |
Yes, and i have no vaccum.indego by default - only when i manually setup an template vacuum... |
I think the vacuum came with 5.1.0 not 5.0.1 |
I am going to close this issue as it is solved. I recommend you guys to continue this discussion over at Discord: |
Bosch changed their auth-system to single-key. Can this integration be updated to support it?
Official mail by Bosch:
The text was updated successfully, but these errors were encountered: