Alexa:我们目前无法 link * - Node、OAuth2 & MongoDB
Alexa: We were unable to link * at this time - Node, OAuth2 & MongoDB
在我尝试将存储在 MongoDB 数据库中的用户帐户与 Alexa 的帐户 linking 功能连接后,确认页面显示“We were目前无法link *"。
我 运行 的 OAuth2 服务器由本教程组成:Building a RESTful API With Node — OAuth2 Server
整个身份验证流程工作正常,甚至访问令牌(称为值)也存储在我的数据库中。
我认为这是最重要的代码块,因为我认为到这里一切正常。
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);
});
});
});
}));
这些是我的 nginx 访问日志:
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)"
希望大家帮忙。
更新:有点滑稽,但 Amazon/Alexa 需要的只是我的令牌对象中的值。所以回调(空,令牌);变成了回调(null,token.value);.
更新:有点滑稽,但是 Amazon/Alexa 需要的只是我的令牌对象中的值。所以callback(null, token);
变成了callback(null, token.value);
.
在我尝试将存储在 MongoDB 数据库中的用户帐户与 Alexa 的帐户 linking 功能连接后,确认页面显示“We were目前无法link *"。
我 运行 的 OAuth2 服务器由本教程组成:Building a RESTful API With Node — OAuth2 Server
整个身份验证流程工作正常,甚至访问令牌(称为值)也存储在我的数据库中。
我认为这是最重要的代码块,因为我认为到这里一切正常。
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);
});
});
});
}));
这些是我的 nginx 访问日志:
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)"
希望大家帮忙。
更新:有点滑稽,但 Amazon/Alexa 需要的只是我的令牌对象中的值。所以回调(空,令牌);变成了回调(null,token.value);.
更新:有点滑稽,但是 Amazon/Alexa 需要的只是我的令牌对象中的值。所以callback(null, token);
变成了callback(null, token.value);
.