在我的基于mean.js的应用程序中,我试图实施护照Twitter身份验证。
我在developer.js中的twitter部分看起来像这样:
twitter: {
clientID: process.env.TWITTER_KEY || ' somekey1234',
clientSecret: process.env.TWITTER_SECRET || 'someSecret1234',
callbackURL: '/auth/twitter/callback'
}
我已经通过Twitter注册,将我的手机号码添加到我的个人资料中,创建了一个应用程序,并获得了消费者密钥和消费者密钥。
我在Twitter上的网站条目如下:
我的回调网址条目如下所示:
http://10.211.55.25:3000/auth/twitter/callback
当我尝试"使用Twitter注册时#34;在我的应用程序中我收到这个错误:
Error: {"errors":[{"code":32,"message":"Could not authenticate you."}]}
at Strategy.parseErrorResponse (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/lib/strategy.js:182:10)
at Strategy.OAuthStrategy._createOAuthError (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/node_modules/passport-oauth1/lib/strategy.js:349:16)
at OAuthStrategy.authenticate (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/node_modules/passport-oauth1/lib/strategy.js:218:41)
at exports.OAuth.getOAuthRequestToken (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/node_modules/passport-oauth1/node_modules/oauth/lib/oauth.js:543:17)
at exports.OAuth._performSecureRequest.passBackControl (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/node_modules/passport-oauth1/node_modules/oauth/lib/oauth.js:397:13)
at IncomingMessage.exports.OAuth._performSecureRequest.request.on.callbackCalled (/home/eugene/dev/node/DataManager_0.2/node_modules/passport-twitter/node_modules/passport-oauth1/node_modules/oauth/lib/oauth.js:409:9)
at IncomingMessage.EventEmitter.emit (events.js:117:20)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)
由于我收到此错误,我的浏览器中的应用网址设置为:
http://10.211.55.25:3000/auth/twitter
我该怎么做才能解决这个问题?
答案 0 :(得分:2)
您在JSON值中有错误(TWITTER_KEY值中存在的空格):
twitter: {
clientID: process.env.TWITTER_KEY || ' somekey1234',
clientSecret: process.env.TWITTER_SECRET || 'someSecret1234',
callbackURL: '/auth/twitter/callback'
}
应该是
twitter: {
clientID: process.env.TWITTER_KEY || 'somekey1234',
clientSecret: process.env.TWITTER_SECRET || 'someSecret1234',
callbackURL: '/auth/twitter/callback'
}