Skip to content
This repository has been archived by the owner on Feb 16, 2024. It is now read-only.

Adding new service fails #23

Closed
tofra opened this issue Jul 4, 2019 · 8 comments
Closed

Adding new service fails #23

tofra opened this issue Jul 4, 2019 · 8 comments

Comments

@tofra
Copy link
Contributor

tofra commented Jul 4, 2019

When I add a new service in Google Home, the DGA login screen is showed. After entering the username and password, it shows: Page not found: 'https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fthuis-50e54'

It looks like the redirect isn't going well.. Here is the console log:

Started httpserver on port  3030
127.0.0.1 - - [04/Jul/2019 21:42:26] "POST /login HTTP/1.1" 404 -
127.0.0.1 - - [04/Jul/2019 21:42:26] "GET /sync HTTP/1.1" 200 -
No user data
1.2.3.4 - - [04/Jul/2019 21:42:38] "GET /oauth?redirect_uri=https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fthuis-50e54&client_id=<clientid>&response_type=code&state=<state>&scope=read&user_locale=nl-NL HTTP/1.1" 307 -
1.2.3.4 - - [04/Jul/2019 21:42:38] "GET /login?client_id=<clientid>&redirect_uri=https%253A%252F%252Foauth-redirect.googleusercontent.com%252Fr%252Fthuis-50e54&redirect=/oauth&state=<state> HTTP/1.1" 200 -
1.2.3.4 - - [04/Jul/2019 21:42:56] "POST /login HTTP/1.1" 301 -
1.2.3.4 - - [04/Jul/2019 21:42:56] "GET /https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fthuis-50e54?code=<code>&state=<state> HTTP/1.1" 404 -

1.2.3.4 is my reverse proxy
< clientid >, < code > and < state > have been replaced

@DewGew
Copy link
Owner

DewGew commented Jul 5, 2019

If you made a new user in Domoticz try to restart Domoticz. Or check your credientials in config.py and in settings in Action on Google

@tofra
Copy link
Contributor Author

tofra commented Jul 5, 2019

Tried restarting, didn't help. Isn't the problem the redirect itself? I assume that the login is sending a location header with a slash in front..

@DewGew
Copy link
Owner

DewGew commented Jul 5, 2019

Importhamn: On the left navigation menu under BUILD, click on Actions. Click on Add Your First Action and choose your app's language(s). Enter the URL for fulfillment,
e.g. https:///smarthome (replace with your actual URL), click Done.
And dont forget to start test in actions also

@tofra
Copy link
Contributor Author

tofra commented Jul 5, 2019

All of this is done..

I also think that the /smarthome URL is needed only áfter the authentication is done. And the authentication isn't successful yet.

I'm guessing that urllib.parse isn't returning the correct value.
https://github.com/DewGew/Domoticz-Google-Assistant/blob/master/auth.py#L64
I'll see if I can find the issue in the code later this week..

@tofra
Copy link
Contributor Author

tofra commented Jul 5, 2019

Found the issue. Google is opening /oauth with parameter redirect url encode (eg. https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fthuis-50e54)
Then you redirect to /login and quote the url again. So it's encoded twice. Then on https://github.com/DewGew/Domoticz-Google-Assistant/blob/master/auth.py#L64 you decode it only once, while it should be done twice.

So you should not encode the url again at https://github.com/DewGew/Domoticz-Google-Assistant/blob/master/auth.py#L34

@DewGew
Copy link
Owner

DewGew commented Jul 22, 2019

Found the issue. Google is opening /oauth with parameter redirect url encode (eg. https%3A%2F%2Foauth-redirect.googleusercontent.com%2Fr%2Fthuis-50e54)
Then you redirect to /login and quote the url again. So it's encoded twice. Then on https://github.com/DewGew/Domoticz-Google-Assistant/blob/master/auth.py#L64 you decode it only once, while it should be done twice.

So you should not encode the url again at https://github.com/DewGew/Domoticz-Google-Assistant/blob/master/auth.py#L34

Thanks for reporting this. Can make a pull request for this issue?

@chatainsim
Copy link

Hello,
I have the same issue.
@tofra Did you manage to correct this ?
Thanks

@DewGew DewGew closed this as completed in daa6c0c Jul 22, 2019
DewGew added a commit that referenced this issue Jul 22, 2019
Fixes double quoting of parameters. Fix #23
@chatainsim
Copy link

Thanks, it's working fine now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants