You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to authenticate to an SP Online site with user name and password but I get this error - Non-whitespace before first tag. On looking at the stack trace and debugging, it looks like the error is coming from the getSamlAssertion method of the AdfsHelper.js file. The method is trying to send a request to and gets a 404 not found response and that is what causes the Non-whitespace before first tag.
I am trying to authenticate to an SP Online site with user name and password but I get this error - Non-whitespace before first tag. On looking at the stack trace and debugging, it looks like the error is coming from the getSamlAssertion method of the AdfsHelper.js file. The method is trying to send a request to and gets a 404 not found response and that is what causes the Non-whitespace before first tag.
(async () => {
const data = await spauth.getAuth('https://[companydomain].sharepoint.com/sites/[sitename]/', {
username: '[username]@[companyname].com',
password: '[password]',
online: true
});
// Optional window and viewport dimentions config
const width = 1920;
const height = 1080;
const browser = await puppeteer.launch();
console.log('starting main');
const page = await browser.newPage();
await page.setExtraHTTPHeaders(data.headers);
await page.setViewport({ width, height });
await page.goto('https://[companydomain].sharepoint.com/sites/[sitename]/SitePages/[pagename]', { waitUntil: 'networkidle0' });
// Save a screenshot of SharePoint page as PDF
await page.pdf({ path: 'sp.pdf', format: 'A4' });
await browser.close();
})()
.catch(console.warn);
AdfsHelper.js -
class AdfsHelper {
static getSamlAssertion(credentials) {
const adfsHost = url.parse(credentials.adfsUrl).host;
const usernameMixedUrl =
https://${adfsHost}/adfs/services/trust/13/usernamemixed
;const samlBody = template(AdfsSamlWsfed_1.template)({
to: usernameMixedUrl,
username: credentials.username,
password: credentials.password,
relyingParty: credentials.relyingParty
});
return config_1.request.post(usernameMixedUrl, { // usernameMixedUrl => 'https://saml.iam.[companyname].com/adfs/services/trust/13/usernamemixed'
body: samlBody,
resolveBodyOnly: true,
headers: {
'Content-Length': samlBody.length.toString(),
'Content-Type': 'application/soap+xml; charset=utf-8'
}
})
.then(xmlResponse => { //Response is '404 not found. \n'
const doc = new xmldoc.XmlDocument(xmlResponse); // This is where the Non-whitespace before first tag error comes up from
The text was updated successfully, but these errors were encountered: