Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.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 {#x27;$严重性';:';错误';&#数据代码';:&#数据分析错误';&#消息';&&#无法处理您发送的数据。&#源&#代理&&&&#_Javascript_Node.js_Oauth 2.0 - Fatal编程技术网

Javascript {#x27;$严重性';:';错误';&#数据代码';:&#数据分析错误';&#消息';&&#无法处理您发送的数据。&#源&#代理&&&&#

Javascript {#x27;$严重性';:';错误';&#数据代码';:&#数据分析错误';&#消息';&&#无法处理您发送的数据。&#源&#代理&&&&#,javascript,node.js,oauth-2.0,Javascript,Node.js,Oauth 2.0,我正在尝试创建连接器,但当我尝试获取访问令牌时,会收到以下错误消息: {$severity':“错误”, “$dataCode”:“DataParsingError”, “$message”:“无法处理您发送的数据。”, “$source”:“Proxy”} 我遵循了以下指南: 是否有人已经遇到此消息并知道如何解决它 这是我的密码: const fetch = require('node-fetch'); const cors = require('cors'); const expr

我正在尝试创建连接器,但当我尝试获取访问令牌时,会收到以下错误消息: {$severity':“错误”, “$dataCode”:“DataParsingError”, “$message”:“无法处理您发送的数据。”, “$source”:“Proxy”}

我遵循了以下指南:

是否有人已经遇到此消息并知道如何解决它

这是我的密码:



const fetch = require('node-fetch');

const cors = require('cors');

const express = require('express');
const app = express();

const https = require('https');
const axios = require('axios');//Requete HTTP

const path = require('path');//chemin
const fs = require('fs');//Lire des fichiers

const PORT = 3443;

const client_id = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
const client_secret = "vvvvvvvvvvvvvvvvv";

var code = '';
var access_token = '';

const GRANT_TYPE = "authorization_code";

const HOME_PAGE_URL = 'https://localhost:3443';
const CALLBACK = '/callback';
const CALLBACK_URL = HOME_PAGE_URL+CALLBACK;//'https://localhost:3443/callback'

var ACCESS_TOKEN = "https://oauth.accounting.sage.com/token";
//&client_id=${client_id}&client_secret=${client_secret}&code=${code}&grant_type=${GRANT_TYPE}&redirect_uri=${CALLBACK_URL}`;


app.use(cors(
    {
        credentials:true,
        origin:'*'
    }
));

app.use(express.static(__dirname + '/public'));








app.get("/callback",async function(req,res){
    code = req.query.code;
    console.log(req.query.code);
    let variable = {
        client_id: client_id, 
        client_secret: client_secret, 
        code:code,
        grant_type:GRANT_TYPE,
        redirect_uri:"https://localhost:3443/callback" 
}
console.log(code);
    fetch(ACCESS_TOKEN,{
        method:'post',
        body:JSON.stringify(variable),
        headers:{
            accept:'*/*',
            //'Content-Type':"application/json",
            'Content-Type': "application/x-www-form-urlencoded",
            'Access-Control-Allow-Origin': "*",
            'Host': "oauth.accounting.sage.com",
            'Accept-Encoding': "gzip, deflate, br",
     
        }

    })
    .then(response => response.json())
    .then(json => console.log(json))
    .catch((error) => console.log(error))
})

const serveur_ssl = https.createServer({
    key:fs.readFileSync(path.join(__dirname,'cert','localhost.key')),
    cert:fs.readFileSync(path.join(__dirname,'cert','localhost.crt'))
},app);

serveur_ssl.listen(PORT,()=>console.log('Adresse : ' + HOME_PAGE_URL +"\nCallback URL : " + CALLBACK_URL));




阿拉丁