Aladin SALEH Posted May 7, 2021 Posted May 7, 2021 Hello, I'm trying to create a web application using sage. So I created a nodejs application (Oauth2 authentication server) to be able to make requests. But I don't know why when I try to authenticate myself the server refuses me access. I have admins rights I don't know where this error comes from. I have searched all afternoon in the documentation but nothing 😕 I hope someone could help me. Here is my code of my nodejs server const express = require('express'); const app = express(); const path = require('path'); const fs = require('fs'); const https = require('https'); const axios = require('axios'); const PORT = 3443; const clientID ='<myclientid>'; const clientSecret ='<myclientsecret>'; app.use(express.static(__dirname + '/public')) app.get('/callback', (req, res) => { const requestToken = req.query.code console.log(req.query.code); axios({ method: 'post', url:`https://oauth.accounting.sage.com/token&grant_type=authorization_code&code=${requestToken}client_id=${clientID}&client_secret=${clientSecret}&redirect_uri=https://localhost:3443/callback`, headers: { accept: 'application/json', } }).then((response) => { const accessToken = response.data.access_token; console.log(accessToken); res.redirect(`/welcome.html?access_token=${accessToken}`) }) }) const sslServer = https.createServer({ key:fs.readFileSync(path.join(__dirname,'cert','localhost.key')), cert:fs.readFileSync(path.join(__dirname,'cert','localhost.crt')) },app); sslServer.listen(PORT,()=>console.log('Adresse : https://localhost:3443/ \nServeur SSL : port : ' + PORT));
Administrators Melanie Lisle Posted May 10, 2021 Administrators Posted May 10, 2021 Hi, Which Sage product are you attempting to connect to? Thanks, Mel
Aladin SALEH Posted May 10, 2021 Author Posted May 10, 2021 26 minutes ago, Melanie Lisle said: Hi, Which Sage product are you attempting to connect to? Thanks, Mel I'm attempting to connect to Sage 50 . Aladin
Administrators Melanie Lisle Posted May 10, 2021 Administrators Posted May 10, 2021 Thanks. If this is the version that's compliant for UK legislation, you'll need to use the SDK to connect. To get access to the SDK you'll need to be a member of the Developer Program and you can get more details by emailing [email protected]. If this is a non-UK variant of the product, you'll be able to find support on Sage City simply select the country that the product is legislatively compliant for then browse to Sage 50cloud Accounts and one of my colleagues will be able to help further. Thanks, Mel
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now