alexa-remote-control: ERROR: no CSRF cookie received
Running v0.21b of the script, configured to use the REFRESH_TOKEN as obtained by the proxy login. Recently, the script has stopped working with the following output;
rapa-3:/config/scripts# ./alexa_remote_control.sh -a
cookie expired, logging in again ...
trying to get CSRF from handlebars
trying to get CSRF from devices-v2
ERROR: no CSRF cookie received
rapa-3:/config/scripts#
I have tried checking the refresh token by logging in via the proxy again. Interestingly, the token has changed - which I did not exepct - so I tried the new one. Same error.
Is there anything I can do to help diagnose this?
Many thanks.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 21
Yes, I saw that. Seems like a reasonable approach. Certainly v0.22 fixes my problem - can verify it works in Home Assistant 2024.4.1 using BusyBox shell.
Thanks for being so responsive and a pleasure to interact with - and thanks for giving your time to support such a useful utility.
You can go ahead and close this as fixed if you wish.
I now set a fixed validity of the cookies to “now + 86400s”. The session cookies always expired after exactly one day (for the past 2.5 years). Worst case we either ask for new cookies to often (once in 24 hours is a lot less than I’ve seen in other implementations), or don’t ask soon enough - in that case any request will fail and a new cookie will be asked for anyways.
Thanks for bearing with me 😄
Can you point me at the docker image you’re using.
This whole date parsing is really driving me crazy. All I wanted is actually not to hammer the Amazon auth service with unnecessary cookie-for-token exchanges. On the other hand the access token is only valid about 24h. So I might as well just have the entire cookie expire some time after that…
Ok, looks like you’re using amazon.co.uk… I don’t have an account there to test with.
Here’s what else you could try.
curl -s -v -b /tmp/.alexa.cookie https://alexa.amazon.co.uk/spa/index.html > /dev/nullcurl -s -v -b /tmp/.alexa.cookie https://alexa.amazon.co.uk/api/strings > /dev/nullSee if there is a Set-Cookie: csrf=… in the output. The curl commands alone won’t write the cookie to file.
When you login using the alexa_cookie app, you implicitly register a new device with your Amazon account (visible in My Apps and Devices). Hence the new refresh token.
The script uses a number of URLs to retrieve the CSRF cookie from. In order to check what’s happening please check the following:
The file is missing a line:
The file should be writable by the user running the script. Curl updates the cookie values automtically.
curl -s -v -b /tmp/.alexa.cookie https://alexa.amazon.de/api/language > /dev/nullcurl -s -v -b /tmp/.alexa.cookie https://alexa.amazon.de/templates/oobe/d-device-pick.handlebars > /dev/nullcurl -s -v -b /tmp/.alexa.cookie https://alexa.amazon.de/api/devices-v2/device?cached=false > /dev/nullIf you use a non-German Amazon account, please change the amazon.de string accordingly.Please let me know what you see! Alex