Alexa Smart Home account linking

I am trying to set alexa.smart_home component. But can not get skill account linked.

Trying to give https://layla.amazon.com/ access to HA gives me “Error: invalid client id or redirect uri”
And in HA I get notification:
Login attempt or request with invalid authentication from x.x.x.x.

Tinkerer suggested on discord that it may be something with reverse proxy but I now removed it and still get same errors. Out of ideas from other posts on forum to try. Just trow anything you have on mind I could try.

I am running hassio on Ubuntu server, and currently went from reverse proxy addon to just using Duckdns addon with Let’s Encrypt and portforward on my router.
And for component everything set per documentation on Alexa smarthome

What address do you have configured in your custom skill in the “account linking” section on amazon developer console?

Authorization URI: https://MY.duckdns.org/auth/authorize
Access Token URI: https://MY.duckdns.org/auth/token
Your Client ID: https://layla.amazon.com/
Scope: smart_home

Hello.

Same problem here. Also using a reverse proxy between WAN and HASS. Dunno if related. Have you fixed this since your post?

Regards,
Chris.

No, I still have not managed to do it.

I recheck everything in configuration multiple times, probably a bug but I have no idea where.
Also it probably have nothing to do with proxy because exposing HA directly to Internet via port forward did not help to me with this while everything else work fine.

I’ve just noticed that the redirect URI from the URL when you try to enable the skill points to https://pitangui.amazon.com/ while mine is supposed to be https://layla.amazon.com/ because I’m from Europe (Belgium).

I manually edited the URL to point the redirect URI to the Layla server, which allows me to successfully login to my HASS instance from the Alexa App and enable an access to my dev Skill. BUUUUUT…no devices were discovered. Nothing’s found, while the Discovery test function successfully shows me everything my HASS instance contains.

This one is about to kill me a second time. :smiley:

2 Likes

Yea that is not the problem i got to. I am also in EU with layla set as redirect URI but can’t get to log in.

I finally managed to get it working.

First of, as I said in my previous post, the redirect URL provided with the skill installation button within the Alexa app is wrong. If I set pitanguy as the redirect URL during the account linking process, I’m able to install the Skill. But Alexa didn’t find any device tho.

Everything on my Amazon account is set like I’m belgian: address, language, region and so on. So I should be able to use layla as the redirect server, while I still can’t.

So I remade the lamba function, this time from the Virginia server instead of the one from Ireland. TADAAAH. I can install the Skill and 157 devices are discovered.

I still don’t know WHY but, well…it works. I hope this will help others one day.

Have a good day.
Chris.

4 Likes

I’ll also give it a try and set everything like I am in USA instead of EU. Guess slower response from working Alexa is better then not working at all.

Hey, some additional clue here.

If you click this link: https://www.amazon.com/hz/mycd/myx#/home/settings/payment
In which Country are you? Mine was set in US. I don’t know why. I Just set it back to Belgium and see what happens if I set everything back to Ireland server.

Thanks for additional clues. :slight_smile:
I am set on Croatia correctly, I hope Amazon is placing Croatia on layla server.

So I went to the URL I gave you earlier today and set my account to Belgium. I was invited to “move my data” to Amazon France (we don’t have such a thing, “Amazon Belgium” but only beer and chocolate ahah) then I deleted my Alexa app cache data on my phone. I set it back, my Skills store was even in french instead of in english. The Skill installation went well on the first try and now it has successfully discovered every device I own.

Did you try to edit the skill installation URL to set the redirect URI to Layla?

Yea its set to leyla, maybe I should try something else.

Same problem here in Germany. Everything is setup as discribed in HA documentation but I still receive “Error: invalid client id or redirect uri”. Function test was succesfull.

Tried to change country settings in the url provided by @vanclec but his url doesn’t direct me to any language settings. Maybe it’s because in germany we are using amazon.de instead of amazon.com

At this moment I don’t know what else to do :frowning:

Ok there seems to be a bug in Home Assistant when trying to link my Dev. Skill with HA. The skill calls the following link:

https://[…].duckdns.org:8123/auth/authorize?client_id=https%3A%2F%2Flayla.amazon.co.uk%2F&response_type=code&state=[…]&scope=smart_home&redirect_uri=https%3A%2F%2Flayla.amazon.com%2Fapi%2Fskill%2Flink%[…]

As you can see the redirect uri is wrong. When correcting the redirect uri to layla.amazon.co.uk I can login but I get a connection error when linking with alexa.amazon.de.

@vanclec
Could you please post a screenshot of the site “https://www.amazon.com/hz/mycd/myx#/home/settings/payment”. Maybe than I will be able to locate it on the German amazon site …

I also came across this issue today, but for me it was a typo on these instructions

it looks like this line

https://layla.amazon.co.uk/ if you are in EU

Should be

https://layla.amazon.com/ if you are in EU

If you change the Client ID it seems to work fine. I’m also using a nginx/letsencrypt reverse proxy

2 Likes

I can confirm @peteclarkez findings, I too had to make the same change to have it working (I see he has already submitted a PR to fix this).

Also, be aware that you need to use the standard 443 SSL port as apparently Alexa skills only work with the standard port (as documented here). I was using a different port and getting an error message after correctly authenticating with HA, that was only fixed when I changed to the standard 443 port.

Thx @peteclarkez and @PedroLamas

When changing “Your Client ID” to “https://layla.amazon.com/” the error message is gone. I’m not using the standard https port and therefore the linking is not possible. Thx for the information that it must be port 443 :slight_smile:

Can anyone post if there is any steps they took to make this work that may not be in documentation?
I do have https://layla.amazon.com/ from before it was fixed in documentations and everything else also as documented while still not being able to run it.

I went through this recently, and the only difference I found was creating the trigger in this bullet. It was slightly different in that you had to click ‘add trigger’ before selecting Alexa Smart Home in the dropdown list.

Everything else was spot on.

What’s your problem?