forked from solid-contrib/web-access-control-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfetch-bob.js
23 lines (20 loc) · 878 Bytes
/
fetch-bob.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const fetch = require('node-fetch');
const { getAuthFetcher, getNodeSolidServerCookie } = require('solid-auth-fetcher');
const oidcIssuer = 'https://solidcommunity.net';
const nssUsername = 'solid-crud-tests-example-2';
const nssPassword = '123';
const origin = 'https://tester';
async function run(url) {
console.log('Getting cookie', { oidcIssuer, nssUsername, nssPassword });
const cookie = await getNodeSolidServerCookie(oidcIssuer, nssUsername, nssPassword);
console.log('Getting fetcher', { oidcIssuer, cookie, origin });
const fetcher = await getAuthFetcher(oidcIssuer, cookie, origin);
console.log('Fetching', { url });
const result = await fetcher.fetch(url);
console.log(result.status, await result.text());
for (let pair of result.headers.entries()) {
console.log(`Response header: ${pair[0]}: ${pair[1]}`);
}
}
// ...
run(process.argv[2]);