bbindreiter / node-red-contrib-alexa-remote2-applestrudel

Node-Red Nodes for interacting with Alexa
https://flows.nodered.org/node/node-red-contrib-alexa-remote2-applestrudel
MIT License
74 stars 20 forks source link

Initialisation does not work for me #165

Closed jwende closed 5 months ago

jwende commented 7 months ago

Hi,

following configuration:

Deployed , open browser from my win PC and sccessfully logged into amazon:

"Amazon Alexa Cookie successfully retrieved. You can close the browser."

but the nodes on NodeRed still shows 'uninitialized'

Thanks J.

jwende commented 7 months ago

tried the same with a local windows installation - target address now 127.0.0.1:3456 - but same result. Is there any option to trace how the code generate/save the cookie ?

Thanks Joerg

jwende commented 7 months ago

I can see the following debug log entries:

25 Nov 13:47:17 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Get pushed activities ... 1 entries in queue (already running: false)
25 Nov 13:47:17 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No authentication check needed (time elapsed 17962)
25 Nov 13:47:17 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Sending Request with {"host":"www.amazon.de","path":"/alexa-privacy/apd/rvh/customer-history-records?startTime=1700830037990&endTime=1701002837990&recordType=VOICE_HISTORY&maxRecordSize=3","method":"GET","timeout":10000,"headers":{}}
25 Nov 13:47:18 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Response: {"customerHistoryRecords":[],"encodedRequestToken":null,"noDataFoundWithinTimeLimit":false,"lastRecordTimestamp":null,"voiceProfileAssociatedWithPerson":false}
25 Nov 13:47:18 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity data []
25 Nov 13:47:18 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity for device G091ET10110404FA not found
25 Nov 13:47:18 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No activities from stored 1 entries found in queue (0)
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Get pushed activities ... 1 entries in queue (already running: false)
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No authentication check needed (time elapsed 20697)
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Sending Request with {"host":"www.amazon.de","path":"/alexa-privacy/apd/rvh/customer-history-records?startTime=1700830040725&endTime=1701002840725&recordType=VOICE_HISTORY&maxRecordSize=3","method":"GET","timeout":10000,"headers":{}}
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Response: {"customerHistoryRecords":[],"encodedRequestToken":null,"noDataFoundWithinTimeLimit":false,"lastRecordTimestamp":null,"voiceProfileAssociatedWithPerson":false}
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity data []
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity for device G091ET10110404FA not found
25 Nov 13:47:20 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No activities from stored 1 entries found in queue (1)
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Get pushed activities ... 1 entries in queue (already running: false)
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No authentication check needed (time elapsed 23391)
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Sending Request with {"host":"www.amazon.de","path":"/alexa-privacy/apd/rvh/customer-history-records?startTime=1700830043419&endTime=1701002843419&recordType=VOICE_HISTORY&maxRecordSize=3","method":"GET","timeout":10000,"headers":{}}
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Response: {"customerHistoryRecords":[],"encodedRequestToken":null,"noDataFoundWithinTimeLimit":false,"lastRecordTimestamp":null,"voiceProfileAssociatedWithPerson":false}
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity data []
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Activity for device G091ET10110404FA not found
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: No activities from stored 1 entries found in queue (2)
25 Nov 13:47:23 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote: Reset expected activities
25 Nov 13:49:26 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote HTTP2-PUSH: Send Ping
25 Nov 13:49:46 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote HTTP2-PUSH: Send Ping
25 Nov 13:50:00 - [debug] [alexa-remote-account:AlexaWin] Alexa-Remote HTTP2-PUSH: Send Ping
25 Nov 13:50:33 - [error] [alexa-remote-routine:ee983c40f64386d9] Account not initialised!
Morinus07 commented 7 months ago

the same; no working,

Kater--S commented 7 months ago

Same here. First I tried with a dockered version of Node-RED (running under IOTstack) and managed to open port 3456. Then I was unsure about the file the persisted data is written into (File Path parameter) but I think I got it right. Just to be sure I also used a non-dockered instance running on a RasPi. I can see that the file is read because JSON errors are shown if there is file content that is not conforming to JSON syntax. I always get the success page after login (without as well as with 2FA) but no cookie information. The procedure described in get_cookie.md does not work because the URL alexa.amazon.com always tells me how to open the mobile Alexa app. No radio stations to be played. I also tried to copy the cookie information from another Amazon session and use it with the "Auth Method" parameter set to "Cookie", but the module keeps logging "please open :3456" which is strange because that method is not active then. There is no documentation about the JSON structure in the "File Path" JSON file, and I cannot simply paste the cookie string into that file.

ABraukmann commented 7 months ago

Same here. Use Proxmox server with Debian instance where node-red is running on a docker container. No cookie or cookie file saved on the system... URL alexa.amazon.de shows always the info: use the Alexa mobile app... Please help ...

abstract-entity commented 7 months ago

Same today, i debug it and i see some trouble in initExt method from lib/alexa-remote-ext.js

const value = await new Promise((resolve, reject) => this.init(config, (err, val) => {
    if (err) {
        // proxy status message is not the final callback call
        // it is also not an actual error
        // so we filter it out and report it our own way
        const begin = `You can try to get the cookie manually by opening http://`;
        const end = `/ with your browser.`;
        const beginIdx = err.message.indexOf(begin);
        const endIdx = err.message.indexOf(end);

        if (beginIdx !== -1 && endIdx !== -1) {
            const url = err.message.substring(begin.length, endIdx);
            proxyActiveCallback(url);
        }
        else {
            //reject(err);
        }
    }
    else {
        resolve(this.cookieData);
    }
}));

this.init callback is called twice, but promise is registered only one time. The first time reject is call to update node status in nodered ui to say: please connect to amazon on http://localhost:3456. Then after connection this.init is called a second time, but promise is already consumed in error, so nothing happen.

To test theory i comment the reject (so node message is broken) but promise can be triggered without error and code continue, my nodes are ready and i can make alexa speak but It seems cookie is not saved to flow context and not save to file.

The first reject is part of normal process for a first authentication, i guess we must add the message to skip rejection condition.

abstract-entity commented 7 months ago

Ok i made a pull request with the right fix: https://github.com/bbindreiter/node-red-contrib-alexa-remote2-applestrudel/pull/166

jwende commented 7 months ago

made an update to my node-red installation and restarted node-red. If I open http://:3456 it shows the following screen:

image
jwende commented 7 months ago

Update: it works if Nodered is local (ie you open 127.0.0.1:3456) I've now copied the cookie file from my windows file system to the raspberyy - and it works. I wonder if the refresh will work locally ...

github-actions[bot] commented 6 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 5 months ago

This issue was closed because it has been inactive for 14 days since being marked as stale.