0
votes

I want to send a request to this Amazon Alexa API.

That page contains the last 50 activities I made with my Amazon Echo. The page returns JSON. Before you can request that page, you need to authorize your account, so the proper cookies are set in your browser.

If I do something simple as:

const rp = require("request-promise");

const options = {
    method: "GET",
    uri: "https://alexa.amazon.com/api/activities?startTime=&size=50&offset=-1",
    json: true
};

rp(options).then(function(data) {
    console.log(data);
}).catch(function(err) {
    console.log(err);
});

I can send a GET request to that URL. This works fine, except Amazon has no idea it's me who's sending the request, because I haven't authorized my NodeJS application.

I've successfully copied ~10 cookies from my regular browser into an incognito tab and authorized that way, so I know copying the cookies will work. After adding them all using tough-cookie, it didn't work, unfortunately. I still got redirected to the signin page (according to the error response).

How do I authorize for this API, so I can send my requests?

1

1 Answers

0
votes

I have been looking for a solution for this too. The best idea I have is to use account linking, but I haven't try it yet. Looks like ASK-CLI has interface for this also, but I can't figure it out how to use it (what is that URL?). For linking account to 3rd party server is not easy, but link it back to Amazon for the json API should not be that complicated.