Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/405.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 带节点js的OUATH2 reddit api_Javascript_Node.js_Api_Reddit - Fatal编程技术网

Javascript 带节点js的OUATH2 reddit api

Javascript 带节点js的OUATH2 reddit api,javascript,node.js,api,reddit,Javascript,Node.js,Api,Reddit,我一直在尝试制作一个应用程序,通过使用NodeJS的api搜索reddit。我无法将ouath2与reddit和浏览器连接。我还尝试在reddit中搜索一个特定的单词。我获取error buffer.361并抛出新的err\u invalid\u arg类型。Size参数的类型必须为number let postData = "grant_type=password&username=my_user_name&password=MyExcellentPassword&

我一直在尝试制作一个应用程序,通过使用NodeJS的api搜索reddit。我无法将ouath2与reddit和浏览器连接。我还尝试在reddit中搜索一个特定的单词。我获取error buffer.361并抛出新的err\u invalid\u arg类型。Size参数的类型必须为number


let postData = "grant_type=password&username=my_user_name&password=MyExcellentPassword";
let username = "my_reddit_id";
let password = "my_reddit_secret";


const Token = function () {
    const options = {
        hostname: "www.reddit.com",
        port: ,
        path: '/api/v1/access_token',
        method: 'POST',
        headers: {
            "Content-Type": "",
            "Content-Length": postData.length,
            "Authorization": "Basic " + new Buffer.aloc(username + ":" + password).toString("base64"),
            "User-Agent": ""
        }
在postdata中放什么,用户名是我认为的clientID,密码是机密的。 另外,在内容类型中放置什么,我需要在buffer.aloc之后将username更改为clientid,并且我需要将密码更改为secret。我应该在路径中发布accestoken