Comments (14)
Hi @dma82,
To use PnPjs, it's dependencies should be imported.
Please check https://pnp.github.io/pnpjs/getting-started/
Import taxonomy (sub package is not enough).
from pnp-auth.
Hi @koltyakov,
Thank you for your reply. Apologies, in my previous example I forgot to show you an extract of my package.json (out of desperation I eventually started to install even the basic libraries (the ones not for CommonJS):
"dependencies": {
"@pnp/common": "^2.11.0",
"@pnp/common-commonjs": "^2.11.0",
"@pnp/graph": "^2.11.0",
"@pnp/graph-commonjs": "^2.11.0",
"@pnp/logging": "^2.11.0",
"@pnp/logging-commonjs": "^2.11.0",
"@pnp/nodejs": "^2.11.0",
"@pnp/nodejs-commonjs": "^2.11.0",
"@pnp/odata": "^2.11.0",
"@pnp/odata-commonjs": "^2.11.0",
"@pnp/sp": "^2.11.0",
"@pnp/sp-commonjs": "^2.11.0",
...
...
},
"devDependencies": {
"typescript": "^4.5.4",
...
...
},
"engines": {
"node": ">=12.13.0"
}
But despite having all dependencies, I'm getting this nasty error...
Thank you.
Regards,
Davide
from pnp-auth.
@dma82, specific PnPjs packages not only should be installed but actually imported. Did you try something structurally like this:
import { bootstrap } from 'pnp-auth';
import { sp } from '@pnp/sp-commonjs';
import "@pnp/sp/taxonomy-commonjs";
bootstrap(sp, authData);
const info = await sp.termStore.groups.getById("338666a8-1111-2222-3333-f72471314e72")
.sets.getById("338666a8-1111-2222-3333-f72471314e72").get();
// ...
from pnp-auth.
Hi @koltyakov,
I've tried this but still no joy:
const bootstrap = require("pnp-auth").bootstrap;
const sp = import("@pnp/sp-commonjs/index.js");
const taxonomy = import("@pnp/sp/taxonomy/index.js");
let url = settings.sharepoint.url;
bootstrap(sp, {
username: settings.sharepoint.auth.username,
password: settings.sharepoint.auth.password },
url);
const set = _.map(await sp.termStores.getByName("<TAXONOMY_NAME>").getTermSetById("<TERM_SET_ID>").terms.get(),
list => _.pick(list, ['Id', 'Name', 'PathOfTerm']));
With pnp-auth v.0.0.4 and sp-taxonomy v.1.3.11 I was able to retrieve the taxonomy list, but those libraries are quite old...
Thank you
from pnp-auth.
LOL, I wanted to ask a fellow from https://github.com/pnp/pnpjs/discussions/2004 discussion who recently was successful with the same setup with taxonomy, but it was you.
from pnp-auth.
LOL! Yes it was me, but with the old libraries! With the new ones somehow I'm having issues... Problem is even with the old libraries I'm having loads of "circular dependency" warnings, so it seems no matter what I do I just incur in issues lol!
from pnp-auth.
Hi @koltyakov,
Just a quick update: instead of using the import at the beginning of my module, I imported it in my function:
async function getList(req, res, next) {
let url = settings.sharepoint.url;
const sp_ = (await import("@pnp/sp-commonjs/index.js"));
const taxonomy = await import("@pnp/sp-commonjs/taxonomy/index.js");
bootstrap(sp_.sp, settings.sharepoint.auth, url);
const set = (await taxonomy.TermStore("").groups.getById("GROUP_ID").sets.getById("<TERM_SET_ID>").terms.get());
debug(set);
next()
}
And now I'm getting a different error lol:
C:\my-project\node_modules\@pnp\odata-commonjs\parsers.js:133
var _this = _super.call(this, message) || this;
^
Error: Error making HttpClient request in queryable [403] Forbidden ::> {"error":{"code":"notAllowed","message":"OAuth only flow is enabled and the call has not been issued from an app."}}
at new HttpRequestError (C:\my-project\node_modules\@pnp\odata-commonjs\parsers.js:133:28)
at Function.<anonymous> (C:\my-project\node_modules\@pnp\odata-commonjs\parsers.js:148:47)
at step (C:\my-project\node_modules\tslib\tslib.js:143:27)
at Object.next (C:\my-project\node_modules\tslib\tslib.js:124:57)
at fulfilled (C:\my-project\node_modules\tslib\tslib.js:114:62)
Same error if I use this:
const set = (await sp_.sp.termStore.groups.getById("GROUP_ID").sets.getById("<TERM_SET_ID>").terms.get());
from pnp-auth.
Which bring us back to pnp/pnpjs#2004: that means I'm going round in circle LOL!
from pnp-auth.
Not promising, but let me try to assemble an example with taxonomy. However, could do it only over the weekend. If you’ll manage finding a solution before it, please let me know.
What are the limitations? Just wondering, what are the stoppers for using TypeScript and latest Node.js and latest versions of other ingredients?
from pnp-auth.
Hi @koltyakov, I surely will let you know if I manage to find a solution. My limitation for using Typescript is that I need to re-use an existing module in CommonJS so at the present moment I can't migrate the whole solution... With regards to Node, I'm actually using the latest version (v.16).
I don't know if the problem now is the credentials (I'm using username and password) or if I'm trying to retrieve the term store in the wrong way...
Thank you in advance for any help you can give me, much appreciated :)
from pnp-auth.
Just offtopic. TypeScript allows using JS (https://www.typescriptlang.org/tsconfig#allowJs) and allows incremental migration.
from pnp-auth.
Hey @dma82,
Looks that the modern Taxonomy API only can be accessed with Azure AD auth.
There is no such strategy currently in node-sp-auth.
from pnp-auth.
Hi @koltyakov ,
Unfortunately I suspected that this strategy was no longer supported but wasn't sure which module was responsible for this...
I might contact their development team and start bugging them lol! :D
Thank you so much for all your time and help on this,, I really appreciated it!
from pnp-auth.
@dma82 I suppose you haven't been successful in the meantime. I just wasted the better half of an afternoon to try the same thing until I stumbled upon this github issue. So no luck with pnp-auth then.
I want to update Taxonomy fields and a test case works, using item.validateUpdateListItem([{FieldName: 'myField', FieldValue: 'taxLabel|taxGUID'}])
. But I need taxLabel and taxGUID to do this. Scraping them from the web page is just no option as there are way too many. Are there maybe other methods to get at the required label/GUID combination?
from pnp-auth.
Related Issues (10)
- Error with sp.createIsolated() HOT 6
- @pnp v3? HOT 4
- Need for bootstrapping @pnp/sp-taxonomy? HOT 2
- Nodejs app - node 10.15 complaining about JSON and global$1.fetch HOT 7
- Provide custom fetch
- Compilation error HOT 2
- Compilation Errors - @pnp/sp @pnp/pnpjs ^2.0.3 and pnp-auth HOT 3
- Is a version planned with support for pnp/sp v2? HOT 7
- Module not Working with new NodeJS Version 13.2 on TypeScript HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnp-auth.