init
This commit is contained in:
commit
15ae3a5a5d
|
@ -0,0 +1,2 @@
|
|||
/node_modules
|
||||
/login
|
|
@ -0,0 +1,31 @@
|
|||
Office365 OAuth2 authenticator
|
||||
==============================
|
||||
|
||||
This project retrieves cookies used to authenticate an user on Sharepoint Online.
|
||||
|
||||
## Requirements
|
||||
|
||||
Tested with NodeJS 16+.
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ git clone https://gitnet.fr/deblan/office365-oauth2-authenticator-2.git
|
||||
$ cd office365-oauth2-authenticator
|
||||
$ make setup
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
```
|
||||
$ cp login.example login
|
||||
$ chmod +x login
|
||||
```
|
||||
|
||||
Edit `login` and replace values of:
|
||||
|
||||
* MS_OFFICE365_SITE
|
||||
* MS_OFFICE365_LOGIN
|
||||
* MS_OFFICE365_PASSWORD
|
||||
|
||||
Then run `./login`.
|
|
@ -0,0 +1,43 @@
|
|||
const playwright = require('playwright');
|
||||
|
||||
const site = process.env.MS_OFFICE365_SITE;
|
||||
const password = process.env.MS_OFFICE365_PASSWORD;
|
||||
const login = process.env.MS_OFFICE365_LOGIN;
|
||||
|
||||
(async () => {
|
||||
const browser = await playwright.chromium.launch();
|
||||
const context = await browser.newContext();
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.goto(site);
|
||||
|
||||
// fill username
|
||||
await page.locator('input[name="loginfmt"]').fill(login);
|
||||
await page.locator('input[type="submit"]').click();
|
||||
// fill password
|
||||
await page.locator('input[name="passwd"]').fill(password);
|
||||
await page.locator('input[type="submit"]').click();
|
||||
// submit remember
|
||||
await page.locator('input[type="submit"]').click();
|
||||
await page.waitForNavigation();
|
||||
|
||||
const cookies = await page.context().cookies();
|
||||
await browser.close();
|
||||
|
||||
let output = {
|
||||
rtFa: null,
|
||||
FedAuth: null,
|
||||
};
|
||||
|
||||
for (let cookie of cookies) {
|
||||
if (cookie.name === 'rtFa') {
|
||||
output.rtFa = cookie.value;
|
||||
}
|
||||
if (cookie.name === 'FedAuth') {
|
||||
output.FedAuth = cookie.value;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(output, 2));
|
||||
|
||||
})();
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
export MS_OFFICE365_SITE="https://foo.sharepoint.com/"
|
||||
export MS_OFFICE365_LOGIN="user@example.com"
|
||||
export MS_OFFICE365_PASSWORD="5eCrEt"
|
||||
|
||||
node ./index.js
|
|
@ -0,0 +1,94 @@
|
|||
{
|
||||
"name": "office365-oauth2-authenticator-2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"playwright": "^1.25.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.25.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.25.1.tgz",
|
||||
"integrity": "sha512-IJ4X0yOakXtwkhbnNzKkaIgXe6df7u3H3FnuhI9Jqh+CdO0e/lYQlDLYiyI9cnXK8E7UAppAWP+VqAv6VX7HQg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"playwright-core": "1.25.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.7.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
|
||||
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/playwright": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.25.1.tgz",
|
||||
"integrity": "sha512-kOlW7mllnQ70ALTwAor73q/FhdH9EEXLUqjdzqioYLcSVC4n4NBfDqeCikGuayFZrLECLkU6Hcbziy/szqTXSA==",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"playwright-core": "1.25.1"
|
||||
},
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
},
|
||||
"node_modules/playwright-core": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.25.1.tgz",
|
||||
"integrity": "sha512-lSvPCmA2n7LawD2Hw7gSCLScZ+vYRkhU8xH0AapMyzwN+ojoDqhkH/KIEUxwNu2PjPoE/fcE0wLAksdOhJ2O5g==",
|
||||
"bin": {
|
||||
"playwright": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@playwright/test": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.25.1.tgz",
|
||||
"integrity": "sha512-IJ4X0yOakXtwkhbnNzKkaIgXe6df7u3H3FnuhI9Jqh+CdO0e/lYQlDLYiyI9cnXK8E7UAppAWP+VqAv6VX7HQg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"playwright-core": "1.25.1"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "18.7.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.13.tgz",
|
||||
"integrity": "sha512-46yIhxSe5xEaJZXWdIBP7GU4HDTG8/eo0qd9atdiL+lFpA03y8KS+lkTN834TWJj5767GbWv4n/P6efyTFt1Dw==",
|
||||
"dev": true
|
||||
},
|
||||
"playwright": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.25.1.tgz",
|
||||
"integrity": "sha512-kOlW7mllnQ70ALTwAor73q/FhdH9EEXLUqjdzqioYLcSVC4n4NBfDqeCikGuayFZrLECLkU6Hcbziy/szqTXSA==",
|
||||
"requires": {
|
||||
"playwright-core": "1.25.1"
|
||||
}
|
||||
},
|
||||
"playwright-core": {
|
||||
"version": "1.25.1",
|
||||
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.25.1.tgz",
|
||||
"integrity": "sha512-lSvPCmA2n7LawD2Hw7gSCLScZ+vYRkhU8xH0AapMyzwN+ojoDqhkH/KIEUxwNu2PjPoE/fcE0wLAksdOhJ2O5g=="
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.25.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"playwright": "^1.25.1"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue