-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
23 lines (21 loc) · 860 Bytes
/
example.js
File metadata and controls
23 lines (21 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(async () => {
const { readFileSync } = require('fs')
const openIdClient = require('./src')
const clientOptions = {
url: 'https://oidc-ver1.difi.no/',
cert: readFileSync('./src/data/public.pem', 'utf-8'),
privateKey: readFileSync('./src/data/private.key', 'utf-8'),
/* privateKeyPassphrase: 'password', // uncomment if privateKey is encrypted */
issuer: 'Din-id',
scope: 'global/kontaktinformasjon.read'
}
try {
const client = await openIdClient(clientOptions)
const { token: { access_token: token } } = client.getConfig()
const payload = { personidentifikatorer: ['23079422568'] }
const data = await client.getData({ url: clientOptions.url + 'kontaktinfo-oauth2-server/rest/v1/personer', token, payload })
console.log(JSON.stringify(data, null, 2))
} catch (error) {
console.error(error)
}
})()