Ad

Alexa: We Were Unable To Link * At This Time - Node, OAuth2 & MongoDB

After I tried to connect my user account, which is stored in a MongoDB database with Alexa it's account linking function, the confirmation page says that "We were unable to link * at this time".

The OAuth2 server I run is made up from this tutorial: Building a RESTful API With Node — OAuth2 Server

The whole authentication flow is working properly and even an access token (called value) is stored in my database.


I think that this is the most important code block, since everything works til here, I think.

server.exchange

server.exchange(oauth2orize.exchange.code(function(client, code, redirectUri, callback) {
  Code.findOne({ value: code }, function (err, authCode) {
    if (err) { return callback(err); }
    if (authCode === undefined) { return callback(null, false); }
    if (client._id.toString() !== authCode.clientId) { return callback(null, false); }
    if (redirectUri !== authCode.redirectUri) { return callback(null, false); }

    // Delete auth code now that it has been used
    authCode.remove(function (err) {
      if(err) { return callback(err); }

      // Create a new access token
      var token = new Token({
        value: uid(256),
        clientId: authCode.clientId,
        userId: authCode.userId
      });

      // Save the access token and check for errors
      token.save(function (err) {
        if (err) { return callback(err); }

        callback(null, token);
      });
    });
  });
}));

These are my nginx access logs:

77.182.19.18 - dmnktoe [10/Mar/2019:15:12:27 +0100] "GET /api/oauth2/authorize?redirect_uri=https://layla.amazon.com/api/skill/link/*&client_id=amazonEchoServices&response_type=code&state=*very-long-state-value* HTTP/1.1" 200 525

77.182.19.18 - dmnktoe [10/Mar/2019:15:12:29 +0100] "POST /api/oauth2/authorize HTTP/1.1" 302 1520 "https://oauth2.healform.de/api/oauth2/authorize?redirect_uri=https://layla.amazon.com/api/skill/link/*&client_id=amazonEchoServices&response_type=code&state=*very-long-state-value*"

54.240.197.10 - amazonEchoServices [10/Mar/2019:15:12:29 +0100] "POST /api/oauth2/token HTTP/1.1" 200 434 "-" "Apache-HttpClient/4.5.x (Java/1.8.0_192)"

Hope anyone can help.


Update: Bit funny, but all Amazon/Alexa need was just the value inside my token object. So callback(null, token); became callback(null, token.value);.

Ad

Answer

Update: Bit funny, but all Amazon/Alexa need was just the value inside my token object. So callback(null, token); became callback(null, token.value);.

Ad
source: stackoverflow.com
Ad