List all secrets
This will return all secrets, along with their id and created_at time. The
value of the secret will never be shown
| Key | Description |
|---|---|
VONAGE_API_KEY | Your Vonage API key (see it on your dashboard). |
VONAGE_API_SECRET | Your Vonage API secret (also available on your dashboard). |
ACCOUNT_ID | The account ID to target |
Write the code
Add the following to list-secrets.sh:
curl "https://api.nexmo.com/accounts/$ACCOUNT_ID/secrets" -H 'Content-Type: application/json' \
-u "$VONAGE_API_KEY:$VONAGE_API_SECRET"Run your code
Save this file to your machine and run it:
Prerequisites
npm install @vonage/server-sdkCreate a file named list-api-secrets.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
apiKey: VONAGE_API_KEY,
apiSecret: VONAGE_API_SECRET,
});Write the code
Add the following to list-api-secrets.js:
vonage.secrets.listSecrets(ACCOUNT_ID)
.then((resp) => console.log(resp))
.catch((error) => console.error(error));Run your code
Save this file to your machine and run it:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a class named ListSecrets and add the following code to the main method:
val client = Vonage {
apiKey(VONAGE_API_KEY)
apiSecret(VONAGE_API_SECRET)
}Write the code
Add the following to the main method of the ListSecrets class:
val secrets = client.account.secrets(ACCOUNT_ID).list()
for (secret in secrets) {
println("ID: ${secret.id} created on: ${secret.created}")
}Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.kt.account with the package containing ListSecrets:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a class named ListSecrets and add the following code to the main method:
VonageClient client = VonageClient.builder()
.apiKey(VONAGE_API_KEY)
.apiSecret(VONAGE_API_SECRET)
.build();Write the code
Add the following to the main method of the ListSecrets class:
List<SecretResponse> response = client.getAccountClient().listSecrets(ACCOUNT_ID);
for (SecretResponse secret : response) {
System.out.println(secret.getId() + " created at " + secret.getCreated());
}Run your code
We can use the application plugin for Gradle to simplify the running of our application. Update your build.gradle with the following:
apply plugin: 'application'
mainClassName = project.hasProperty('main') ? project.getProperty('main') : ''Run the following gradle command to execute your application, replacing com.vonage.quickstart.account with the package containing ListSecrets:
Prerequisites
Install-Package VonageCreate a file named ListAllSecrets.cs and add the following code:
using Vonage;
using Vonage.Request;
using System;Add the following to ListAllSecrets.cs:
var response = await client.AccountClient.RetrieveApiSecretsAsync(ACCOUNT_ID);Write the code
Add the following to ListAllSecrets.cs:
Console.WriteLine($"First Secret Response: {response.Embedded.Secrets[0].Id}");Prerequisites
composer require vonage/clientCreate a file named list-secrets.php and add the following code:
Run your code
Save this file to your machine and run it:
Prerequisites
pip install vonage python-dotenvWrite the code
Add the following to list-all-secrets.py:
from vonage import Auth, Vonage
from vonage_account import VonageApiSecret
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
response: list[VonageApiSecret] = client.account.list_secrets()
print(response)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named list-all-secrets.rb and add the following code:
Run your code
Save this file to your machine and run it: