homebridge-plugins / homebridge-resideo

The Homebridge Resideo plugin allows you to access your Resideo devices from HomeKit.
ISC License
37 stars 8 forks source link

Bug: BAD URL #741

Closed gruler closed 2 years ago

gruler commented 2 years ago

Describe The Bug

Relink url is not working

To Reproduce

Try to relink a Honeywell account

Expected behavior

Be able to relink account

Relevant log output

Received this message when trying to link my account.
I am on Homebridge Honeywell Home
homebridge-honeywell-home v11.4.3

                {"code":400, "message":"The redirect URL provided does not match the redirect URL registered for the app."}

Config for homebridge-honeywell-home

{
    "bridge": {
        "name": "Homebridge 9F92",
        "username": "0E***92",
        "port": 51318,
        "pin": "*"
    },
    "accessories": [],
    "platforms": [
        {
            "name": "Config",
            "port": 8581,
            "auth": "none",
            "theme": "auto",
            "tempUnits": "f",
            "lang": "auto",
            "platform": "config"
        },
        {
            "name": "HoneywellHome",
            "options": {
                "thermostat": {
                    "thermostatSetpointStatus": "PermanentHold"
                },
                "roompriority": {
                    "priorityType": "PickARoom"
                }
            },
            "platform": "HoneywellHome",
            "_bridge": {
                "username": "******:B5",
                "port": 49320
            }
        },
        {
            "name": "orbit",
            "email": "*****",
            "password": "******",
            "platform": "orbit"
        },
        {
            "refreshToken": "eyJhbGciOiJIUzUxMiIsImprdSI6Ii9vYXV0aC9pbnRlcm5hbC9qd2tzIiwia2lkIjoiYzEyODEwMGIiLCJ0eXAiOiJKV1QifQ.eyJpYXQiOjE2NjIzMDUzOTUsImlzcyI6IlJpbmdPYXV0aFNlcnZpY2UtcHJvZDp1cy1lYXN0LTE6MGUyMTk4NGQiLCJyZWZyZXNoX2NpZCI6InJpbmdfb2ZmaWNpYWxfYW5kcm9pZCIsInJlZnJlc2hfc2NvcGVzIjpbImNsaWVudCJdLCJyZWZyZXNoX3VzZXJfaWQiOjU2NDg0NjksInJuZCI6Il9hODNqQzduLVAyWXRBIiwic2Vzc2lvbl9pZCI6ImI5NTQzNTIyLWQ3NjctNDgwYy05ZGVhLWQzNDFmNWQ3YWRkZiIsInR5cGUiOiJyZWZyZXNoLXRva2VuIn0.sLzu33mNJ_mOV6bqPtsqHsyPs9Jo70Nd851Zu-NBMlqHilrRHagpg20RhEn73z50-Nbeje0JPicf89F5xu3Dbg",
            "platform": "Ring",
            "_bridge": {
                "username": "*:33",
                "port": 49368
            }
        },
        {
            "country": "US",
            "language": "en-US",
            "auth_mode": "token",
            "refresh_token": "2123ade9406d338790bbdcd3f8ea99c651147c9af1945a57009e2a322fbb465e8b8cb6fc745639546b491d51928c065b",
            "username": "****",
            "password": "****",
            "devices": [
                {
                    "id": "ab549af3-5795-1828-bbe6-402f86ed617a",
                    "name": "Dryer",
                    "type": "DRYER"
                },
                {
                    "id": "c022d8d7-1d0a-1a55-9fd2-f8b95a6f5022",
                    "name": "Front Load Washer",
                    "type": "WASHER"
                }
            ],
            "thinq1": true,
            "refresh_interval": 60,
            "platform": "LGThinQ"
        }
    ]
}

Screenshots

No response

Device & Model

Honeywell Thermostat

Node.js Version

v16.17.0

NPM Version

not sure how to find

Homebridge Version

v1.5.0

Homebridge Honeywell Home Plugin Version

v11.4.3

Homebridge Config UI X Plugin Version

v4.50.1

Operating System

macOS

donavanbecker commented 2 years ago

What is your relink url in the Honeywell developer app?

And what is the relink url in the plugin?

gruler commented 2 years ago

Where do I get that info?

donavanbecker commented 2 years ago

Hit Unlink:

Screenshot 2022-09-04 at 11 56 52 AM

Then you should see this screen. Does it look like this?

Screenshot 2022-09-04 at 11 57 39 AM
gruler commented 2 years ago

I previously had unlinked the account. Now when I click on Honeywell Home Settings I get the attached a page that looks like this. When I enter the credentials, I get the error message. {"code":400, "message":"The redirect URL provided does not match the redirect URL registered for the app."}

donavanbecker commented 2 years ago

you need to respond directly on Github, I am not seeing anything you sent.

gruler commented 2 years ago

I previously had unlinked the account. Now when I click on Honeywell Home Settings I get the attached a page that looks like this. When I enter the credentials, I get the error message. {"code":400, "message":"The redirect URL provided does not match the redirect URL registered for the app."}

image

donavanbecker commented 2 years ago

click the back arrow and send that screenshot.

gruler commented 2 years ago

image

donavanbecker commented 2 years ago

Is that the url here the same as the developer app?

gruler commented 2 years ago

I went into Resido and found this http://localhost:8585/

image

gruler commented 2 years ago

I changed it to include AUTH at the end, but now I am getting cannot connect to Local Host

donavanbecker commented 2 years ago

Try without including with at the end in the app.

donavanbecker commented 2 years ago

I may have to update some things. But you should be able to get it to work.

gruler commented 2 years ago

Same error after removing the AUTH {"code":400, "message":"The redirect URL provided does not match the redirect URL registered for the app."}

mgldan commented 2 years ago

I am seeing a very similar error. I tried to relink today. 

Screen Shot 2022-09-05 at 1 54 09 PM Screen Shot 2022-09-05 at 1 57 51 PM



donavanbecker commented 2 years ago

@mgldan, Your callback url in the Honeywell app is 8581 and should be 8585

gruler commented 2 years ago

Donavan, mine is 8585 and I am getting the below error. I've tried with and without AUTH in the callback

image

mgldan commented 2 years ago

@donavanbecker Thanks, I’m not sure how they got out of sync. It must have been while I was trying to troubleshoot. I changed the callback URL at Honeywell’s site and it cleared up.

I definitely had the same 400 error as the OP at one point. Maybe the fix was some combination of clearing my cache, deleting my old Honeywell app, and relinking…

donavanbecker commented 2 years ago

Need to update the ui so it doesn't post the auth in that UI, that's confusing.

gruler commented 2 years ago

So, do I need to do something to get it to work or do you need to do something with the plugin?

Thanks, Jim

donavanbecker commented 2 years ago

Still researching. I think Honeywell might have did something recently. Because mine was working and now it isn't.

rrmills7777 commented 2 years ago

Not sure if it's relevant at this point, but I'm definitely experiencing the same issue. I currently can't link my honeywell app to the HB plugin.

donavanbecker commented 2 years ago

Please try latest beta

rrmills7777 commented 2 years ago

I will be happy to do that, but I don't know how :)

rrmills7777 commented 2 years ago

I figured it out. Now says I'm running v11.4.5-beta.4. Error persists.

rrmills7777 commented 2 years ago

Made it a bit further... the server.js in the beta has not picked up the dropping of the 'auth' tag. I manually made the changes in my installation, and now it gets further when linking. It makes me put in my Resideo login/pass, and I can then select my thermostats. Eventually it just says 'welcome to the server' and the plugin never picks up a config or gets any further. So progress, but still stuck.

donavanbecker commented 2 years ago

@rrmills7777 can you put those changes into a pull request and then we can look into this further. I just haven't had time.

rrmills7777 commented 2 years ago

You already made 2 commits on Sep 8 for this issue. The first removed the 'auth' from index.html and server.js in homebridge-ui, the second reverted the change to server.js. You just need to revert that last commit.

donavanbecker commented 2 years ago

Is this what you are talking about?

https://github.com/donavanbecker/homebridge-honeywell-home/commit/c0ef2c5bdeae9501ab83ddce7d5faae901f9f3c9

I tried removing auth in server.js and that didn't work.

Need to look over documentation again to see what they changed.

rrmills7777 commented 2 years ago

I have it working. It involves changing a switch statement to look for nothing, which I don't love.

case 'auth': becomes case '':

If you want i can put in a pull request and see if you have a better idea than I do about how to handle that case.

rrmills7777 commented 2 years ago

OK, I honestly have no idea how to do a pull request. Here are the changes I had to make to get it to work:

index f587cbf..f21ef70 100644
--- a/homebridge-ui/public/index.html
+++ b/homebridge-ui/public/index.html
@@ -254,7 +254,7 @@
          }
          showIntro = () => {
             const introLink = document.getElementById('introLink')
-            document.getElementById('copyMe').value = 'http://' + hostname + ':8585/'
+            document.getElementById('copyMe').value = 'http://' + hostname + ':8585'
             introLink.addEventListener('click', () => {
                homebridge.showSpinner()
                document.getElementById('pageIntro').style.display = 'none'

diff --git a/homebridge-ui/server.js b/homebridge-ui/server.js
index 2617fc9..63cf1bd 100644
--- a/homebridge-ui/server.js
+++ b/homebridge-ui/server.js
@@ -29,12 +29,12 @@ class PluginUiServer extends HomebridgePluginUiServer {
               this.secret = query.secret;
               this.hostname = query.host;
               const url = 'https://api.honeywell.com/oauth2/authorize?' +
-                'response_type=code&redirect_uri=' + encodeURI('http://' + this.hostname + ':8585/auth') + '&' +
+                'response_type=code&redirect_uri=' + encodeURI('http://' + this.hostname + ':8585') + '&' +
                 'client_id=' + query.key;
               res.end('<script>window.location.replace(\'' + url + '\');</script>');
               break;
             }
-            case 'auth': {
+            case '': {
               if (query.code) {
                 const code = query.code;
                 const auth = Buffer.from(this.key + ':' + this.secret).toString('base64');
@@ -46,7 +46,7 @@ class PluginUiServer extends HomebridgePluginUiServer {
                 curlString += '-d "';
                 curlString += 'grant_type=authorization_code&';
                 curlString += 'code=' + code + '&';
-                curlString += 'redirect_uri=' + encodeURI('http://' + this.hostname + ':8585/auth');
+                curlString += 'redirect_uri=' + encodeURI('http://' + this.hostname + ':8585');
                 curlString += '" ';
                 curlString += '"https://api.honeywell.com/oauth2/token"';
                 try {
juan2three commented 2 years ago

I'm also running into this issue only on HOOBS though. Works fine on HB UI. The url on HOOBS is https://homebridge-honeywell.iot.oz.nu/link-account which isn't a valid URL even though I set it as my redirect URL on the HoneyWell dev side

donavanbecker commented 2 years ago

@juan2three I don't develop this for HOOBs. So can't help you there.

I would recommend switching to homebridge

juan2three commented 2 years ago

@juan2three I don't develop this for HOOBs. So can't help you there.

I would recommend switching to homebridge

I did, it works perfectly fine. HOOBs is claiming you are the developer of the official plugin, I left a review but I'm not sure if you want to report it

donavanbecker commented 2 years ago

@juan2three I don't develop this for HOOBs. So can't help you there.

I would recommend switching to homebridge

I did, it works perfectly fine. HOOBs is claiming you are the developer of the official plugin, I left a review but I'm not sure if you want to report it

I am the developer of this plugin, but HOOBs does their own kind of homebridge and UI, so I can't guarantee things will work, since I only develop for homebridge and homebridge UI.

rrmills7777 commented 2 years ago

Issue still exists for 1.0.0 release of plugin renamed to resideo

donavanbecker commented 2 years ago

Must only be for specific accounts, mine is working fine.

mgldan commented 2 years ago

Thanks, I’m not sure how they got out of sync. It must have been while I was trying to troubleshoot. I changed the callback URL at Honeywell’s site and it cleared up. On Sep 5, 2022, 8:00 PM -0400, Donavan Becker @.***>, wrote:

Your callback url in the Honeywell app is 8581 and should be 8585 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

donavanbecker commented 2 years ago

Nice

gruler commented 2 years ago

Thanks, it is working now for me as well.