【发布时间】:2018-09-03 02:45:42
【问题描述】:
我已经尝试了这个线程上的所有东西,但没有运气。 Node.js https pem error: routines:PEM_read_bio:no start line
我正在尝试向 google API 发出一个非常简单的请求,以询问频道的信息。
我拥有的东西:
- 已安装 npm 请求
- Google API 密钥 - 导出到环境变量
- 我正在使用 cloud9(这就是其他解决方案可能不起作用的原因)
我可以使用相同的方法向 yahoo 天气 API 发出请求。
var request = require('request');
request("https://www.googleapis.com/youtube/v3/channels?",{
part: "snippet,contentDetails,statistics",
id: "UCd534c_ehOvrLVL2v7Nl61w",
key: process.env.YOUTUBE_API_KEY
}, function(err, response, body){
if (err){
console.log(err);
}
console.log(body);
});
这是完整的错误
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
at Error (native)
at Object.createSecureContext (_tls_common.js:85:17)
at Object.exports.connect (_tls_wrap.js:1033:48)
at Agent.createConnection (https.js:82:22)
at Agent.createSocket (_http_agent.js:195:26)
at Agent.addRequest (_http_agent.js:157:10)
at new ClientRequest (_http_client.js:160:16)
at Object.exports.request (http.js:31:10)
at Object.exports.request (https.js:202:15)
at Request.start
(/home/ubuntu/workspace/node_modules/request/request.js:748:32)
undefined
感谢您的帮助!
【问题讨论】:
-
您是否正在使用authorize your request 的 API 密钥?您可以尝试改用 OAuth,“包含googleapis.com/auth/youtubepartner-channel-audit 范围的授权令牌”。
标签: node.js google-api youtube-api cloud9 npm-request