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

Unable to setup authentication with Minut Point #91583

Closed
robkirk opened this issue Apr 18, 2023 · 59 comments · Fixed by #118243
Closed

Unable to setup authentication with Minut Point #91583

robkirk opened this issue Apr 18, 2023 · 59 comments · Fixed by #118243

Comments

@robkirk
Copy link

robkirk commented Apr 18, 2023

The problem

I have created a client secret in api.minut.com and inserted these credentials into my configuration.yaml file. Home Assistant then detects this and shows me a 'Discovered' and 'Configure' button.

When I click this is shows me a dialogue with a 'Link' button on this which is supposed to accept the Access. Whenever I do this I get a web page served from Minut asking me to Grant Home Assistant permission. When I do this I get the following JSON returned
{"message":"Unable to issue redirect for OAuth 2.0 transaction","code":"server_error","status":500,"name":"AuthorizationError","error_key":"internal_server_error"}

My Home Assistant has external internet access which has worked for over a year successfully.

What version of Home Assistant Core has the issue?

core-2023.4.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Minut Point

Link to integration documentation on our website

https://www.home-assistant.io/integrations/point/

Diagnostics information

Unable to find any 'Minut' log lines in the Home Assistant log.

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

I have had this working a few months ago but Minut may have changed something as when I renewed my subscription it said I was on a Legacy Pro plan.

Note I am still a Pro subscriber.

@home-assistant
Copy link

Hey there @fredrike, mind taking a look at this issue as it has been labeled with an integration (point) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of point can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign point Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


point documentation
point source
(message by IssueLinks)

@Kimusabi
Copy link

I'm also getting an error during the authentication phase, home assistant is providing a link to configure authorisation, however when I click the link and receive the following error:
{"error":"redirect_uri_mismatch","error_description":"Invalid redirect URI"}

Granted this is not the same as the original posters error, but this is similar in that I cannot configure or finish the setup of Minut Point with Home Assistant.

I had configured the URI to match the documentation i.e. as per the example http://localhost:8123/api/minut, however looking over the Minut API documentation the URL for authentication appears to be different:
https://api.minut.com/v8/oauth/authorize?response_type=code&client_id=CLIENT_ID&redirect_uri=REDIRECT_URI

Where the link provided in Home Assistant is pointing to v5 of the API:
https://api.minut.com/v5/oauth/authorize?response_type=code&client_id=*****&state=*****

@justinb186
Copy link

I can confirm I am having the same issue as @Kimusabi - I am getting the same error:

{"error":"redirect_uri_mismatch","error_description":"Invalid redirect URI"}

I had previously enabled Point in the past in home assistant using the same Client ID, Secret and Redirect URI successfully. But I removed the integration from Home Assistant because I was having issues with it - and now am stuck not being able to add it back in.

@fredrike
Copy link
Contributor

fredrike commented May 3, 2023

Where the link provided in Home Assistant is pointing to v5 of the API:

The Minut integration is created for the v5 of the API.

I had configured the URI to match the documentation i.e. as per the example http://localhost:8123/api/minut

Do you run HomeAssistant locally (on the same machine as you are trying to configure the integration) the url must be http://<your homeassistant url>/api/minut, most of the time <your home assistant url> will be homeassitant.local:8123.

@Kimusabi
Copy link

Kimusabi commented May 3, 2023

Do you run HomeAssistant locally (on the same machine as you are trying to configure the integration) the url must be http://<your homeassistant url>/api/minut, most of the time <your home assistant url> will be homeassitant.local:8123.

I don't use it locally, in the Minut api-clients section I configured it as http://homeassistant.local:8123, and then input the client id and secret in the config file. But am still getting the error when trying to configure it.

@bencarver
Copy link

Any updates on this? I'm having the same issue.

@smackie
Copy link

smackie commented Jul 5, 2023

Going to add another person to the "redirect_uri_mismatch" headache. I have a horrible feeling this has to do with the newish my.homeassistant.io "helper" grabbing the oauth2 stream and putting the wrong URI in it. This appears to have happened to a few other modules but I'm damned if I can work out how to disable it well enough to fully check this.

I have a fully ssl setup and access my home assistant setup with https://foo.smackie.io:8123 - the URL that's registered with Minut is https://foo.smackie.io:8123/api/minut and that works - it returns OK when fetched. However, whatever the HA code is returning on the URI reply to OAUTH isn't this.

@fredrike - any thoughts on this?

@beeper77
Copy link

I get also an error message if I want to authenticate throught the link. I use the internal urls. If I click on the link the browser opens this url: https://api.minut.com/v5/oauth/authorize?response_type=code&client_id=5555&state=66666. After I have done the authentication I get a {"message":"Unable to issue redirect for OAuth 2.0 transaction","code":"server_error","name":"AuthorizationError","error_key":"internal_server_error"}.

If the modify the Url to something like this: https://api.minut.com/v8/oauth/authorize?response_type=code&client_id=555&state=666&redirect_uri=http://homeassistant.local:8123/api/minut (modifying from v5 to v8 and add the redirect_uri parameter) I get an Ok message. But the plugin does not get the feedback. I am not sure if this helps but hopefully it put someone to the correct direction.

@tonylucas1870
Copy link

tonylucas1870 commented Sep 6, 2023

Expanding on what @beeper77 has said, which is what got me thinking.

I've got to the bottom of this (well, I think I have). I don't know if Minut have accidentally put through changes from a newer API version (as https://api.minut.com/v5 still does suggest it's v5 responding not a later version) but it has changed behavior.

Newer versions expect the redirect_uri to be included in BOTH the initial request and then the code-> token exchange request. The current 'pypoint' library which Minut Point uses doesn't include it on either stage. I've seen this before; some implementations of Oauth require it to be specified at request time, some don't, but it appears Minut have moved the goal posts at some point.

If it's missing in the first request you get the error as described further up this thread. If it's missing in the second request you get a 'invalid_grant: Invalid Authorization Code' error from the API (tested this manually myself and got consistent results, even if this is an incorrect error message)

Sadly my knowledge of python is non existent so I can't suggest the code fixes, but I can lay out what needs to happen:

The initial request to /oauth/authorize needs to change from:

https://api.minut.com/v5/oauth/authorize?response_type=code&client_id=xxx to be:

https://api.minut.com/v5/oauth/authorize?response_type=code&client_id=xxx&redirect_uri=http://yyy

(changing xxx and yyy as needed of course)

Then (as a CURL example because it's a POST) the code->token request needs to change from:

curl -X POST "https://api.minut.com/v5/oauth/token"
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d grant_type=authorization_code&client_id=xxx&client_secret=zzz&code=aaa to be:

curl -X POST "https://api.minut.com/v5/oauth/token"
-H "Accept: application/json"
-H "Content-Type: application/x-www-form-urlencoded"
-d grant_type=authorization_code&redirect_uri=http://yyy&client_id=xxx&client_secret=zzz&code=aaa

(Again, replacing where appropriate)

@fredrike I hope this is useful in helping you or someone else make the relevant changes.

@ripburger
Copy link

Unfortunately I am having the same issue, anyone been able to resolve it?

@fredrike
Copy link
Contributor

Thanks @tonylucas1870 I'll see if I can update the library to support this.

Quite annoying that you version pin and then things change anyway..

@FerretMonger
Copy link

Same issue here. Hoping for a fix ❤️

@dahlma
Copy link

dahlma commented Sep 15, 2023

Any progress? Also hoping for a fix <3

@fredrike
Copy link
Contributor

Hi,

I did have a look at it and yes it seems like they have changed quite a bit for the auth part. My kickstarter account seems to be some kind of basic+ account and API is only available for pro plan users. If Minut doesn't upgrade my account I will not have means of testing the new protocol, hence I I think we unfortunately have to pull Minut support from Ha.

@dahlma
Copy link

dahlma commented Sep 18, 2023 via email

@fredrike
Copy link
Contributor

fredrike commented Sep 25, 2023

I've found a solution for the auth issue, here is a fix: fredrike@d2eaf12

I've found some other issues too so will try to mitigate them too.

@fredrike fredrike mentioned this issue Sep 25, 2023
20 tasks
@ripburger
Copy link

Great, thanks for the effort! Will this be available in the next HA update? :)

@robkirk
Copy link
Author

robkirk commented Oct 2, 2023 via email

@fredrike fredrike mentioned this issue Oct 13, 2023
20 tasks
@fredrike
Copy link
Contributor

Great, thanks for the effort! Will this be available in the next HA update? :)

Who knows, the high quality requirements are holding my fix back so it might come down to the Point integration will be pulled #101967 (comment)

@bencarver
Copy link

Great, thanks for the effort! Will this be available in the next HA update? :)

Who knows, the high quality requirements are holding my fix back so it might come down to the Point integration will be pulled #101967 (comment)

@fredrike I for one really appreciate your efforts!!

@robkirk
Copy link
Author

robkirk commented Dec 13, 2023

Any update on this?

@FerretMonger
Copy link

I would love for this to be fixed. Is there someone in the HA core group that could potentially help out with this?

@fredrike
Copy link
Contributor

I have a working solution but it doesn't adhere to the standards in Ha I have not had time to re-write it.

@robkirk
Copy link
Author

robkirk commented Jan 2, 2024

I'd love to help, I'm an software engineer but I don't tend to do a lot of coding anymore and I'm not that familiar with Python. However, is your code in a branch somewhere that people can pull and see if they can get it adhere to the standards.
Is this the latest iteration - fredrike@d2eaf12

@fredrike
Copy link
Contributor

fredrike commented Jan 3, 2024

I'd love to help, I'm an software engineer but I don't tend to do a lot of coding anymore and I'm not that familiar with Python. However, is your code in a branch somewhere that people can pull and see if they can get it adhere to the standards. Is this the latest iteration - fredrike@d2eaf12

Yes, that version works but it is not OK to add more config options..

@fredrike
Copy link
Contributor

fredrike commented Jan 3, 2024

I suggest you to have a look at this as that is working but needs adoption to the new oauth flow..

https://github.com/fredrike/home-assistant/tree/point-redirect-uri
fredrike@point-redirect-uri

@rcouchman111
Copy link

Would love to see this fixed, if there is any testing or assistance I can provide please let me know.

@juntta
Copy link

juntta commented Jan 30, 2024

Yes, Point API configured with Redirect URI if that is what you meant.

Weird, reloaded Home Assistant again and then the "normal" authentication window came up:
image
with right client id etc

but, after clicking link and logged in

https://api.minut.com/v5/oauth/decision:
{"message":"Unable to issue redirect for OAuth 2.0 transaction","code":"server_error","name":"AuthorizationError","error_key":"internal_server_error"}

@fredrike
Copy link
Contributor

I think you should paste the redirect URI in the dialog, strange that the translation didn't work.

@juntta
Copy link

juntta commented Jan 30, 2024

Ok, I copypasted my redirect URI on the same browser tab with Point API consent dialog and:

http://homeassistant.local:8123/api/minut
OK!

but HA window shows when I click Submit:

image

@ripburger
Copy link

Yes, Point API configured with Redirect URI if that is what you meant.

Weird, reloaded Home Assistant again and then the "normal" authentication window came up: image with right client id etc

but, after clicking link and logged in

https://api.minut.com/v5/oauth/decision: {"message":"Unable to issue redirect for OAuth 2.0 transaction","code":"server_error","name":"AuthorizationError","error_key":"internal_server_error"}

I get this same error, unfortunately!

@fredrike
Copy link
Contributor

I'll do some more testing and get back to you, sorry for this.

@juntta
Copy link

juntta commented Jan 30, 2024

Dont be sorry, we're (or I at least) just too impatient 🤣

@rleatherb
Copy link

Remove the point integration

How do you remove the Point integration that cannot be configured? Under Integrations I have "Discovered" showing the Minut Point, with the only option being to Configure. Until it is configured then I don't seem to have the option to delete it, but of course the configuration doesn't work.

@fredrike
Copy link
Contributor

fredrike commented Feb 6, 2024

Ok I did some more testing and it seems like we have to use the custom_component route.

I'm still working on getting this to work but if you like to try use the zip above and extract so you have a point folder inside your custom_component folder.

@fredrike
Copy link
Contributor

fredrike commented Feb 6, 2024

So, this is what i have:
Screenshot 2024-02-06 at 19 38 13

Starting the configuration flow should get you this (I had to remove the point folder in homeassistant/components/:
Screenshot 2024-02-06 at 19 39 12

If the dialog don't have text it is probably due to bad translation but this is a start.

@juntta
Copy link

juntta commented Feb 6, 2024

Ok I did some more testing and it seems like we have to use the custom_component route.

I'm still working on getting this to work but if you like to try use the zip above and extract so you have a point folder inside your custom_component folder.

I actually went this route myself and results were the ones I posted here last week. I didn't remove the "original" plugin though.

@fredrike
Copy link
Contributor

fredrike commented Feb 6, 2024

Ok I did some more testing and it seems like we have to use the custom_component route.
I'm still working on getting this to work but if you like to try use the zip above and extract so you have a point folder inside your custom_component folder.

I actually went this route myself and results were the ones I posted here last week. I didn't remove the "original" plugin though.

Try to remove the original too, as we need to make sure that it is loaded correctly.

@juntta
Copy link

juntta commented Feb 18, 2024

Any progress with this?

I tried to remove the original plugin but it didn't have any effect though. ☹️

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@juntta
Copy link

juntta commented May 20, 2024

Is there any recent updates on this integration?

I can test this again if this should work now.

@menaibluey
Copy link

menaibluey commented May 20, 2024 via email

@fredrike
Copy link
Contributor

I'm terrible sorry for not updating you on this. The problem is that although I have a working solution it doesn't follow the standards of HA so it will not get merged.

I've been swamped with work both professionally and privately hence have not priortized to get it merged to HA. I would however try to find some time in the near future to get this to follow the standards and get merged..

Just a teaser, this is how it looks when it is working (UniFi Network is shown as we are using the same identifier).

image

@FerretMonger
Copy link

FerretMonger commented May 21, 2024 via email

@robkirk
Copy link
Author

robkirk commented May 21, 2024 via email

@FerretMonger
Copy link

FerretMonger commented May 21, 2024 via email

@juntta
Copy link

juntta commented May 21, 2024

I'm happy to contribute to a pizza/beer/coffee fund to get this work done.

I'm sure others would be too.

Rob

👍👍

@fredrike
Copy link
Contributor

Let's move all discussion to the forum, https://community.home-assistant.io/t/integration-with-minut-point/8749.

@issue-triage-workflows
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@fredrike
Copy link
Contributor

I'm waiting for review on #118243..

@github-actions github-actions bot removed the stale label Aug 21, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet