nodejs怎么通过第三方api的oauth2
发布于 7 年前 作者 QwerBoy 3985 次浏览 来自 问答

这是代码 var https=require(‘https’);

var options = { hostname: ‘api.cnblogs.com’, port:‘443’, path: ‘/token’, method: ‘post’, auth: ‘Basic clientId:clientSercre’ };

var req = https.request(options, function(res){ console.log(‘状态码:’, res.statusCode); console.log(‘请求头:’, res.headers);

res.on('data', function(d) {
	console.log('d:'+d);
});

});

req.on(‘error’, function(e) { console.error(‘e:’+e); }); req.end();

错误信息是{“error”:“invalid_clientId”,“error_description”:“Client Id format is invalid”}

5 回复

這不是nodejs的問題

@captainblue2013 能告诉我怎么做吗?刚接触nodejs

@captainblue2013 我看node https的官方文档,好像只有auth basic方式的认证!

我做过一些尝试,可以给你参考一下:https://github.com/somax/oauth-gitlab

回到顶部