node-sp-auth
package and I am hoping to get some help here hopefully.getAuth()
with client_id
and client_secret
only, everything seems to be working ok (in that I don't get any errors back), but when the promise resolves, the access token comes back as undefined, so the "headers" object looks like this: {'Authorization': 'Bearer undefined'}
.This is an exact replication of the error
Hi,
I'm currently trying to develop a electron/typescript application and very new to it.
Reading through the documentation of you package, it looks like I should be able to handle authentication and requests for on prem severs using 'User credentials through the http ntlm handshake', through this package called 'sp-jsom-node'.
I noticed the minimal setup section for typescript and made a few alterations. See test code below.
const authOptions: IAuthOptions = {
username: 'JohnDoe',
password: 'S3cureP@ss',
domain: 'myDomainName'
};
const authContext: IJsomNodeContext = {
siteUrl: siteUrl,
authOptions: authOptions,
modules: [ 'core' ],
envCode: '2016'
};
const ctx = new JsomNode().init(authContext).getContext();
const oWeb = ctx.get_web();
const oLists = oWeb.get_lists();
console.log(oLists);
I get a error from 'new JsomNode()' within electrons developer tool window that states:
'Uncaught Error: Cannot find module 'net'
at webpackEmptyContext (eval at ./node_modules/defaultable sync recursive (app.js:1157:1), <anonymous>:2:10)
at Object.workaround_require (defaultable.js?6987:49:1)
at require (defaultable.js?6987:77:1)
at eval (server.js?663d:9:1)
at defaulter (defaultable.js?6987:83:1)
at defaultable (defaultable.js?6987:63:1)
at good (defaultable.js?6987:174:1)
at Object.eval (server.js?663d:5:1)
at eval (server.js:242:30)
at Object../node_modules/hbo-dnsd/server.js (chunk-vendors.js:3945:1)'.
I suspect it has something to do with the fact that I'm using Typescript and there's a missing module for NET which might be used within JsomNode?
I'm not too sure if the issue is with my implementation or just my lack of understanding.
I'm basically trying to create a authenticated context without using the 'private.json' file and instead using direct user input to the application.
Hey @Darkstar69er,
JSOM/CSOM is an old API which sometimes is useful for the places where modern API doesn't work or have gaps. But in a usually not needed until you know a very specific case you'd can't managed with REST for example.
It runs in Node.js environment. You can't run a Node.js code in browser.
The error is not connected with TypeScript. The message you're getting is Webpack which can't bundle code for browser as it can't find Node.js 'net' and browser is not a server side JS environment.
In Electron app you should route requests through Electron's backend to make it work.
Hi Guys, hope you're doing just fine.
Can you assist me? What i'm missing?
const listTitle = 'sites';
const request = sprequest.create(credentials);
let urlTest = 'url';
request.requestDigest(urlTest)
.then(digest => {
return request.post(`${urlTest}/_api/web/lists/GetByTitle('${listTitle}')/items`, {
headers: {
'X-RequestDigest': digest,
"content-type": "application/json;odata=verbose",
},
body: {
__metadata: { 'type': `SP.Data.${listTitle}ListItem` },
Title: 'Test'
}
});
})
.then((data) => {
expect(data.statusCode).to.equal(201);
})
.catch((err) => {
console.log(err.message);
});
it returns:
Response code 400 (Bad Request)
Hi, I'm noob here. English not my mother tongue. So forgive me if I typo or grammar mistake.
I am following the tutotial on this page with node.js method for OneDrive business to WebDav
https://github.com/skleeschulte/basic-to-sharepoint-auth-http-proxy
So far all npm command already install and apply; but my access to localhost:3000 is failed.
The things to ask is, I'm totally clueless how to use node-sp-auth as authentication?
I'm lost with:
Create authentication headers and perform http request
Is it a file? Where it should be save? and under what name?
I don't have experience using node.js ; just pick it up few days ago when I discover the tutorial.
Hopefully, you guys can answer me. The node.js is running on machine Synology DS916+ DSM7