bentleyj68 Posted August 21, 2017 Report Share Posted August 21, 2017 Has anyone got any Node js examples of accessing Caspio data using OAUTh2? Quote Link to comment Share on other sites More sharing options...
0 douvega Posted September 29, 2017 Report Share Posted September 29, 2017 Not sure why you would use Node js to access the API but I would recommend using this third party service to make proper API calls: https://www.futuresuite.net/products/api-library.php Quote Link to comment Share on other sites More sharing options...
0 Harbinger Posted March 2, 2019 Report Share Posted March 2, 2019 Hi @bentleyj68 what in specific are you looking at in using Node.js with Oauth2? Do you have a self-built API? Quote Link to comment Share on other sites More sharing options...
0 douvega Posted December 10, 2019 Report Share Posted December 10, 2019 In case someone is looking to connect to the CASPIO API using NodeJS, here is the code sample to get the authentication token. const https = require('https'); const querystring = require('querystring'); const data = querystring.stringify({ "grant_type": "client_credentials", "client_id": "[INSERT CLIENT ID HERE]", "client_secret": "[INSERT CLIENT SECRET HERE]" }); const options = { protocol: 'https:', host: '[INSERT CASPIO ACCOUNT HERE].caspio.com', path: '/oauth/token', method: 'POST', headers: { 'Content-Type': 'application/json' } }; const req = https.request(options, (res) => { console.log(`statusCode: ${res.statusCode}`); res.on('data', (d) => { process.stdout.write(d); }); }); req.on('error', (error) => { console.error(error); }); req.write(data); req.end(); Quote Link to comment Share on other sites More sharing options...
0 SinJunYoung Posted December 14, 2019 Report Share Posted December 14, 2019 Just to add links for reference, here's: https://howto.caspio.com/web-services-api/ Quote Link to comment Share on other sites More sharing options...
0 aaronthesoftwaremechanic Posted September 7, 2022 Report Share Posted September 7, 2022 On 12/10/2019 at 11:39 AM, douvega said: In case someone is looking to connect to the CASPIO API using NodeJS, here is the code sample to get the authentication token. const https = require('https'); const querystring = require('querystring'); const data = querystring.stringify({ "grant_type": "client_credentials", "client_id": "[INSERT CLIENT ID HERE]", "client_secret": "[INSERT CLIENT SECRET HERE]" }); const options = { protocol: 'https:', host: '[INSERT CASPIO ACCOUNT HERE].caspio.com', path: '/oauth/token', method: 'POST', headers: { 'Content-Type': 'application/json' } }; const req = https.request(options, (res) => { console.log(`statusCode: ${res.statusCode}`); res.on('data', (d) => { process.stdout.write(d); }); }); req.on('error', (error) => { console.error(error); }); req.write(data); req.end(); query params is legacy, but does not work either way. Quote Link to comment Share on other sites More sharing options...
Question
bentleyj68
Has anyone got any Node js examples of accessing Caspio data using OAUTh2?
Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.