GithubHelp home page GithubHelp logo

vgrem / csomnode Goto Github PK

View Code? Open in Web Editor NEW
20.0 20.0 11.0 753 KB

SharePoint Client Object Model (CSOM) API for Node.js

License: MIT License

JavaScript 100.00%
javascript sharepoint sharepoint-client

csomnode's People

Contributors

andrei-markeev avatar forivall avatar kasinaat avatar siddharth-vaghasia avatar vgrem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

csomnode's Issues

authCtx.acquireTokenForUser - error: The specified member name is either invalid or empty

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.

Getting errors when trying to use SP.ClientContext in an Azure function

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());
});

});

Exception has occurred: RangeError from Auth example in Readme

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)

Include implementation details in README.md

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.

Example doesn't work

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.