Good day, @s-KaiNet . I have been using sp-request to scrape pages within a site collections on SP2013 for a couple years now. I now need to update my node code to work with SPO, app-only permissions. I'm able to authenticate to SPO without issue however, the same technique to grab the HTML of a SP page no longer works.
With SP2013, I could simply pass the full URL and the response would return the HTML. When I try the same with SPO I get an authentication error. Here's the current code:
/*jshint esversion: 6 */
const sprequest = require('sp-request');
let spr = sprequest.create({
siteUrl: 'https://tenant.org/sites/dev',
clientId: '1beab0a4-a10d-4a6b-xxxx-b4c247faa95f',
clientSecret: 'SZvu9Gmbxxxx9fHGeZ+KC9QBxxxx1ApHAlLeNAermug='
});
const url = encodeURI('https://tenant.org/sites/dev');
function peek(url) {
url = url.toLowerCase();
return new Promise(function () {
spr(url)
.then(function (response) {
console.log(response.body);
})
.catch(function (err) {
console.log('Something went wrong.... ' + err);
});
});
}
peek(url);
npm run build
then npm run publish
with environment variable for authentication (https://github.com/koltyakov/node-sp-auth-config#environment-variables). Please leave an issue with the request to add Azure DevOps sample in the repository I’ll add a generic sample, but it’s really just binding env vars for auth (making sure prod mode is on) and the ordinary frontend project pipeline actions specifics.
Hi @koltyakov ,
I am having some issues on the establishing connection
Below is the code I am using
# Creating private file from multiline variable from matrix
# Encoding secrets in private file
- script: |
touch ./config/private.json && cat <<EOF > ./config/private.json
$(private.json)
EOF
SPAUTH_ENV=production gulp config
displayName: 'Establishing connection'
The error is showing:
<< was unexpected at this time.
I am not sure if it is due to my private.json?
Thank you
Hey!
I just started out using your amazing package.
Now im having a problem:
I wanted to go through your samples, and it worked fine till i wanted to create a list item.
Here is my Code: https://i.imgur.com/bxYWB1g.png
I get the following Error: HTTPError: Response code 400 (Bad Request)
at EventEmitter.<anonymous> (C:\Users\mathe\source\repos\CryptoChat\node_modules\sp-request\node_modules\got\dist\source\as-promise.js:118:31).
Also im really new to nodejs (?and rest?). So if i want for example to read out the number of list items for example. Where can i find the headers i need for that etc?
Im happy for every response!
Sincerly Matheo
can pnp not authenticate on-prem on its own?
Sure thing, no.