vgrem / csomnode Goto Github PK
View Code? Open in Web Editor NEWSharePoint Client Object Model (CSOM) API for Node.js
License: MIT License
SharePoint Client Object Model (CSOM) API for Node.js
License: MIT License
Thanks for this,
As far as I can see, you have included the sp.js
etc in this release, could you specify this in the README.md?
I was unsure wether this library used the REST API or however it's done. I bet others are wondering as well.
Hi Guys,
I am following the Andrei Markeev article - (https://markeev.com/posts/jsom-azure-function/), and using csom-node in my azure function to connect with sharepoint. the AuthenticationContext method is successful and able to connect to sharepoint site using appid and appsecret. But after that in the line where we are creating the clientContext using new SP.ClientContext("url"), i am getting the error unable to find ClientContext of undefined. In all the example code, the SP object is used without any imports or requires entry. Can you guys please advise how i can resolve the issue?
I tries to use an import statement
import {SP} from "csom-node";
if i use the statement, i am able to build and debug the function. (I am using VS Code). When i debug, I am able to see the SP object and if expanded, i can also see the ClientContext function under that. but if i continue the execution, the error
Cannot read property 'ClientContext' of undefined
const csomApi = require("csom-node");
const AuthenticationContext = require('csom-node').AuthenticationContext;
csomapi.setLoaderOptions({url: settings.url}); //set CSOM library settings
var authCtx = new AuthenticationContext(settings.url);
authCtx.acquireTokenForUser(process.env.username, settings.password, function (err, data) {
**var ctx = new SP.ClientContext("/"); //set root web**
authCtx.setAuthenticationCookie(ctx); //authenticate
//retrieve SP.Web client object
var web = ctx.get_web();
ctx.load(web);
ctx.executeQueryAsync(function () {
console.log(web.get_title());
},
function (sender, args) {
console.log('An error occured: ' + args.get_message());
});
});
Hi!
I've tried to run the example:
var csomapi = require('csom-node');
var settings = {
url: "SP Online Url",
username: "login",
password: "password"
};
csomapi.setLoaderOptions({url: settings.url}); //set CSOM library settings
var authCtx = new AuthenticationContext(settings.url);
authCtx.acquireTokenForUser(settings.username, settings.password, function (err, data) {
var ctx = new SP.ClientContext("/"); //set root web
authCtx.setAuthenticationCookie(ctx); //authenticate
//retrieve SP.Web client object
var web = ctx.get_web();
ctx.load(web);
ctx.executeQueryAsync(function () {
console.log(web.get_title());
},
function (sender, args) {
console.log('An error occured: ' + args.get_message());
});
});
But it doesn't work. Nothing happens. Tried the debugger and found that execution stucked at ctx.executeQueryAsync
call. Neither success nor fail calbacks called.
My code works on one site fine
On another, the default login redirects to a custom page, and on this site I am getting the error
responseText: '{"error_description":"Unsupported security token."}',
I am not able to get past the initial call to AuthenticationContext.acquireTokenForUser. It always hits an error with the message "The specified member name is either invalid or empty".
I am basically following the taxonomy example in this repo, but tweaking it to work from an Azure Function.
I am trying to authenticate to a SharePoint Online instance which is federated using my domain user name.
Hi!
I'm trying to authenticate on a Sharepoint Foundation 2013 (on premises), but it fails.
http://myintranetserver/_forms/default.aspx?wa=wsignin1.0 return an error also in a browser.
Also authentication is done before as we have an Active Directory, so passing username and password should not be needed.
Any hint welcome
Thank you
Bruce
You might have some idea what's going on here, but if it's user error I fully accept that and you can close this.
My code is the following (basically from your readme)
var csomapi = require('csom-node');
var settings = {
url: "https://www.cmich.edu",
username: "userId",
password: "MyPa$$"
};
csomapi.setLoaderOptions({url: settings.url}); //set CSOM library settings
var authCtx = new AuthenticationContext(settings.url);
authCtx.acquireTokenForUser(settings.username, settings.password, function (err, data) {
var ctx = new SP.ClientContext("/"); //set root web
authCtx.setAuthenticationCookie(ctx); //authenticate
//retrieve SP.Web client object
var web = ctx.get_web();
ctx.load(web);
ctx.executeQueryAsync(function () {
console.log(web.get_title());
},
function (sender, args) {
console.log('An error occured: ' + args.get_message());
});
});
I hit F5 in VSCode to debug and get this whole mess:
Exception has occurred: RangeError
RangeError: Maximum call stack size exceeded
at Function.Object$getType [as getType] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:450:38)
at Object.Sys$_isInstanceOfType [as _isInstanceOfType] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:999:31)
at Function$_validateParameterType [as _validateParameterType] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:206:30)
at Function$_validateParameter [as _validateParameter] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:126:18)
at Function$_validateParams [as _validateParams] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:80:22)
at Function.Error$argumentUndefined [as argumentUndefined] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:348:22)
at Function$_validateParameterType [as _validateParameterType] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:157:23)
at Function$_validateParameter [as _validateParameter] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:126:18)
at Function$_validateParams [as _validateParams] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:80:22)
at Function.String$format [as format] (e:\src\gitlab\App-Utilities\Sharepoint-Image-Optimizer\node_modules\csom-node\lib\sp_modules\msajaxbundle.debug.js:516:22)
hi i want to ask this project still support?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.