{"id":21655944,"url":"https://github.com/koltyakov/sp-auth-puppeteer-sample","last_synced_at":"2025-04-11T21:30:59.930Z","repository":{"id":42227836,"uuid":"152231190","full_name":"koltyakov/sp-auth-puppeteer-sample","owner":"koltyakov","description":"Puppeteer \u0026 node-sp-auth example","archived":false,"fork":false,"pushed_at":"2022-12-08T02:22:56.000Z","size":187,"stargazers_count":5,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T17:22:56.348Z","etag":null,"topics":["authentication","javascript","puppeteer","sharepoint","sharepoint-online","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/koltyakov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-10-09T10:19:04.000Z","updated_at":"2024-02-09T21:44:54.000Z","dependencies_parsed_at":"2023-01-25T03:31:08.734Z","dependency_job_id":null,"html_url":"https://github.com/koltyakov/sp-auth-puppeteer-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2Fsp-auth-puppeteer-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2Fsp-auth-puppeteer-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2Fsp-auth-puppeteer-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/koltyakov%2Fsp-auth-puppeteer-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/koltyakov","download_url":"https://codeload.github.com/koltyakov/sp-auth-puppeteer-sample/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248482874,"owners_count":21111397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","javascript","puppeteer","sharepoint","sharepoint-online","typescript"],"created_at":"2024-11-25T08:37:53.235Z","updated_at":"2025-04-11T21:30:59.893Z","avatar_url":"https://github.com/koltyakov.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Puppeteer \u0026 node-sp-auth example\n\n\u003e Demonstrates a way of headless browser automation with SharePoint.\n\n## About Puppeteer\n\n[Puppeteer](https://github.com/GoogleChrome/puppeteer) is a Node library which provides a high-level API to control Chrome or Chromium over the DevTools Protocol. Puppeteer runs headless by default, but can be configured to run full (non-headless) Chrome or Chromium.\n\n## Dependencies\n\n```bash\nnpm install\n```\n\n## Build\n\n```bash\nnpm run build\n```\n\n## Auth\n\n```bash\nnpm run auth\n```\n\nProvide auth options for SPO or On-Prem SharePoint site.\n\nAuth options are stored in `./config/private.json`\n\nSee more [here](https://github.com/koltyakov/node-sp-auth-config).\n\n## Run: sp-auth mechanism\n\n```bash\nnpm run start\n```\n\nor\n\n```bash\nts-node ./src/main.ts\n```\n\nShould start the Puppeteer (in headless mode) authenticated to SharePoint with [node-sp-auth](https://github.com/s-KaiNet/node-sp-auth).\n\n## Run: interactive auth and O365 automation\n\n```bash\nnpm run start:interactive\n```\n\nor\n\n```bash\nts-node ./src/interactive.ts\n```\n\nInteractive mode emulates user credentials input which let us navigate to any Office 365 section, e.g. Central Administration, etc., and run some UI automation or testing.\n\nE.g., [./src/interactive](./src/interactive.ts) script outputs a list of surveys and a number of responses from MS Forms.\n\n## Sample\n\n```typescript\nimport * as puppeteer from 'puppeteer';\nimport { authPuppeteer } from './auth';\n\n(async () =\u003e {\n\n  const browser = await puppeteer.launch();\n  const page = await browser.newPage();\n  const siteUrl = await authPuppeteer(page);\n  // Since this time page is authenticated in SharePoint\n\n  await page.goto(siteUrl, { waitUntil: 'networkidle2' });\n\n  /* Here comes Puppeteer logic: UI tests, screenshots, etc. */\n\n  // Save a screenshot of SharePoint page as PDF\n  await page.pdf({ path: 'sp.pdf', format: 'A4' });\n\n  // For other goodies check for Puppeteer API:\n  // https://github.com/GoogleChrome/puppeteer/blob/v1.9.0/docs/api.md\n\n  await browser.close();\n\n})()\n  .catch(console.warn);\n```\n\n## CI Sample\n\nIn CI environment configure [SPAuth variables](https://github.com/koltyakov/node-sp-auth-config#environment-variables). E.g.:\n\n- SPAUTH_SITEURL=https://contoso.sharepoint.com/sites/my-site\n- SPAUTH_USERNAME=username@contoso.onmicrosoft.com\n- SPAUTH_PASSWORD=secret\n\nClone the sample:\n\n```bash\ngit clone git@github.com:koltyakov/sp-auth-puppeteer-sample.git\n```\n\nInstall dependencies and build:\n\n```bash\nnpm ci\nnpm run build\n```\n\nRun automation. E.g.:\n\n```bash\nnode ./build/main --ci \"--scenarios\" \"workbench,screenshot\"\n```\n\nEmbed approach into your favorite UI tests framework.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoltyakov%2Fsp-auth-puppeteer-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkoltyakov%2Fsp-auth-puppeteer-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkoltyakov%2Fsp-auth-puppeteer-sample/lists"}