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);.
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);
.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM