node.js - httpsProxyAgent 未定义
问题描述
我正在通过passport-linkedin 将linkedin 身份验证与我的node.js 集成。它最初工作正常。我被重定向到登录/注册页面。用户正在输入他们的详细信息,但是在进行身份验证时出现错误
InternalOAuthError: Failed to obtain access token
at Strategy.OAuth2Strategy._createOAuthError (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:379:17)
at C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:166:45
at C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:199:18
at ClientRequest.<anonymous> (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:170:5)
at emitOne (events.js:116:13)
at ClientRequest.emit (events.js:211:7)
at TLSSocket.socketErrorListener (_http_client.js:387:9)
at emitOne (events.js:116:13)
at TLSSocket.emit (events.js:211:7)
at emitErrorNT (internal/streams/destroy.js:64:8)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
我检查了堆栈溢出并知道这是因为公司代理。我添加了
var HttpsProxyAgent = require('https-proxy-agent');
if (process.env['https_proxy']) {
httpsProxyAgent = new HttpsProxyAgent(process.env['https_proxy']);
}
和
options.agent = httpsProxyAgent;
在 oauth2.js 中。但现在我收到了这个错误
ReferenceError: httpsProxyAgent is not defined
at exports.OAuth2._request (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:126:19)
at exports.OAuth2.getOAuthAccessToken (C:\Users\SU40006113\Desktop\second\node_modules\oauth\lib\oauth2.js:197:8)
at loaded (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:164:20)
at NullStore.verify (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\state\null.js:9:3)
at Strategy.OAuth2Strategy.authenticate (C:\Users\SU40006113\Desktop\second\node_modules\passport-oauth2\lib\strategy.js:210:26)
at attempt (C:\Users\SU40006113\Desktop\second\node_modules\passport\lib\middleware\authenticate.js:361:16)
at authenticate (C:\Users\SU40006113\Desktop\second\node_modules\passport\lib\middleware\authenticate.js:362:7)
at Layer.handle [as handle_request] (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:275:10)
at Function.handle (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:174:3)
at router (C:\Users\SU40006113\Desktop\second\node_modules\express\lib\router\index.js:47:12)
我已经安装了https-proxy-agent。
是什么导致了错误?
解决方案
推荐阅读
- c++ - C ++中模板<>的包装函数
- python - Python,Pandas, - 如何在列中搜索整数
- c# - EF 中用户定义的列名和表名
- yaml - 没有为 api 网关创建标签
- angular - 将两个 ngValue 和两个 ngModel 放在一起很热?
- reactjs - 你可以在同一个网站上使用 React 平滑滚动和 React Router Links 吗?
- flutter - RangeSlider 偶尔显示空白标签
- c++ - 如何创建一个 (f)16 重复 n 次的数字?
- javascript - 如何在三行而不是 1 行中显示数据?
- javascript - 累积函数数组中每个函数的返回值