0

我正在尝试对 bitly 进行身份验证,以便可以使用链接缩短器并跟踪用户的指标。我的实现是这样的:

passport.use(new BitlyStrategy({
    clientID: "my client id here",
    clientSecret: "my secret here",
    callbackURL: "http://website.com/auth/bitly/callback"
},
function (token, tokenSecret, profile, done) {
// Code to put it in the server here.
}
));

路线如下所示:

app.get('/auth/bitly',
    passport.authenticate('bitly'));

app.get('/auth/bitly/callback',
passport.authenticate('bitly', { failureRedirect: '/', failureFlash: true, failureFlash: 'Invalid bitly Authentication try again.' }),
function(req, res) {
    // Successful authentication, redirect home.
    res.redirect('/');
});

现在我已经做了我能想到的一切来让它工作,但我总是想出这个愚蠢的错误:

Application has thrown an uncaught exception and is terminated:
TypeError: Parameter 'url' must be a string, not undefined
at Object.urlParse [as parse] (url.js:92:11)
at [object Object]._request (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:56:22)
at [object Object].get (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:196:8)
at Strategy.userProfile (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\lib\passport-bitly\strategy.js:76:16)
at loadIt (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\lib\passport-oauth\strategies\oauth2.js:221:17)
at Strategy._loadUserProfile (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\lib\passport-oauth\strategies\oauth2.js:236:25)
at C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\lib\passport-oauth\strategies\oauth2.js:127:14
at C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:178:7
at passBackControl (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:107:9)
at IncomingMessage.<anonymous> (C:\DWASFiles\Sites\twitter-mongo\VirtualDirectory0\site\wwwroot\node_modules\passport-bitly\node_modules\passport-oauth\node_modules\oauth\lib\oauth2.js:124:7

任何人都知道这意味着什么,我应该从哪里开始修复它?

4

3 回答 3

4

我刚刚修复了错误passport-bitly并提出了拉取请求:https ://github.com/dreadjr/passport-bitly/pull/1

@Bitly API:护照是在节点世界中获取访问令牌的一种流行方式,所以让这个策略起作用是件好事。

于 2013-11-28T16:48:39.733 回答
2

我们对此处的护照库并不十分熟悉,但我们最近在此处发布了一些使用多种语言(包括 node.js)的简单 OAuth 代码示例:http: //bit.ly/bitlyoauthexamples

于 2013-07-12T14:22:09.997 回答
0

如果你使用 dreadjs 的护照位策略,你会得到这个错误。将strategy.js文件替换为simo 的 fork中的文件。

截至目前,Simo 的更正尚未合并到 dreadjr 的护照位存储库中。我可以验证更正是否有效。基本上最初的驼峰式_profileUrl应该在strategy.js_profileURL的第 49 行。正确的行是:

this._profileURL = options.profileURL || 'https://api-ssl.bitly.com/v3/user/info';

在检索所需的 JSON 信息时也进行了更改。

于 2014-05-25T09:55:55.220 回答