gpt4 book ai didi

node.js - 在node.js中使用bitly策略实现 Passport 认证

转载 作者:太空宇宙 更新时间:2023-11-04 02:59:10 27 4
gpt4 key购买 nike

我正在尝试对 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

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

最佳答案

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

@Bitly API:通行证是在 Node 世界中获取访问 token 的一种流行方式,因此让这种策略发挥作用是件好事。

关于node.js - 在node.js中使用bitly策略实现 Passport 认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17602574/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com