【发布时间】:2015-04-23 00:48:13
【问题描述】:
我目前有一个带有自定义登录(电子邮件/密码)的 Meteor 应用程序。我计划要求用户链接他们的 Twitter 帐户(如果可用,每个用户有多个 Twitter 帐户),以便我可以代表他们提出 API 请求(获取推文、发布推文、搜索推文等)
我相信要做到这一点,我需要用户的 oauth_token 和 oauth_secret。
我正在使用 Tim Haines 的 'twitter' 包来尝试实现这一点。我还使用以下资源: Twitter.requestCredential function response https://github.com/timhaines/test-accounts/blob/master/test-accounts.js
我可以打开登录对话框,输入 Twitter 用户名/密码,然后我会得到一个令牌字符串,每次登录尝试都不同。所以我知道Twitter.requestCredential() 正在工作。但是,当我将令牌传递给代码Twitter.retrieveCredential(token) 中的行时,它什么也不返回(未定义)。
这是我的客户端代码(直接来自上面的链接):
Twitter.requestCredential(function(tokenOrError) {
if(tokenOrError && tokenOrError instanceof Error) {
console.log('Error:' + tokenOrError);
} else {
Meteor.call('retrieveTwitterCredential', tokenOrError, function(error, result) {
if(error)
console.log(error.reason);
else {
console.log('DEMO ONLY - DON\'T send unfiltered credentials to the client on a production app');
console.log('Result:', result);
}
});
}
});
这是我的服务器端代码(直接来自上面的链接):
console.log(token);
credential = Twitter.retrieveCredential(token);
console.log(credential);
if(credential instanceof Error)
throw new Meteor.Error(500, credential.message);
else
return credential;
“凭据”似乎未定义。在过去的两周里,我一直在努力解决这个问题,所以如果有人能提供帮助,我们将不胜感激。
提前致谢!
【问题讨论】:
标签: meteor