Revoke a secret
To revoke an API secret, you must send a DELETE request to the secret management API.
You must have at least one API secret at all times.
| 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 |
VONAGE_SECRET_ID | The ID of the secret to delete. |
Write the code
Add the following to revoke-secret.sh:
curl -X DELETE "https://api.nexmo.com/accounts/$ACCOUNT_ID/secrets/$ACCOUNT_SECRET_ID" \
-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 delete-api-secret.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 delete-api-secret.js:
vonage.accounts.deleteSecret(ACCOUNT_ID, ACCOUNT_SECRET_ID)
.then(() => console.log('Secret deleted'))
.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 file named RevokeSecret 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 RevokeSecret file:
client.account.secrets(ACCOUNT_ID).delete(ACCOUNT_SECRET_ID)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 RevokeSecret:
Prerequisites
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a file named RevokeSecret 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 RevokeSecret file:
client.getAccountClient().revokeSecret(ACCOUNT_ID, ACCOUNT_SECRET_ID);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 RevokeSecret:
Prerequisites
Install-Package VonageCreate a file named RevokeSecret.cs and add the following code:
using Vonage;
using Vonage.Request;
using System;Add the following to RevokeSecret.cs:
var response = await client.AccountClient.RevokeApiSecretAsync(ACCOUNT_SECRET_ID, ACCOUNT_ID);Write the code
Add the following to RevokeSecret.cs:
Console.WriteLine($"Secret Revoked: {response}");Prerequisites
composer require vonage/clientCreate a file named delete-a-secret.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 revoke-secret.py:
from vonage import Auth, Vonage
client = Vonage(Auth(api_key=VONAGE_API_KEY, api_secret=VONAGE_API_SECRET))
client.account.revoke_secret(ACCOUNT_SECRET_ID)Run your code
Save this file to your machine and run it:
Prerequisites
gem install vonageCreate a file named revoke-a-secret.rb and add the following code:
Run your code
Save this file to your machine and run it: