-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
35 lines (28 loc) · 1.11 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const akeyless = require('akeyless')
var akeylessCloud = require('.')
const AkeylessClient = new akeyless.ApiClient();
AkeylessClient.basePath = 'https://api.akeyless.io';
const api = new akeyless.V2Api(AkeylessClient)
async function getSecret(key, opts) {
try {
const authResult = await api.auth(akeyless.Auth.constructFromObject(opts))
const token = authResult.token
const someObject = akeyless.GetSecretValue.constructFromObject({
names: [key],
token: token
})
const data = await api.getSecretValue(someObject)
console.log('API called successfully. Returned data: ' + JSON.stringify(data))
return JSON.stringify(data)
} catch (e) {
console.log(JSON.stringify(e, null, 2))
}
}
async function getSecretWithCloudId() {
const accessType = "azure_ad"
const cloudId = await akeylessCloud.getCloudId(accessType)
const optsAws = { 'access-id': "p-xxxxxxxxxxxx", 'access-type': accessType, 'cloud-id': cloudId }
const secret = await getSecret("my-secret", optsAws)
console.log(secret)
}
getSecretWithCloudId()