List Users
In this code snippet you learn how to get a list Users associated with an Application.
Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Write the code
Add the following to list-users.sh:
curl "https://api.nexmo.com/v1/users" \
-H 'Authorization: Bearer '$JWT\
-H 'Content-Type: application/json'Run your code
Save this file to your machine and run it:
Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
npm install @vonage/server-sdkCreate a file named list-users.js and add the following code:
const { Vonage } = require('@vonage/server-sdk');
const vonage = new Vonage({
applicationId: VONAGE_APPLICATION_ID,
privateKey: VONAGE_PRIVATE_KEY,
});Write the code
Add the following to list-users.js:
const run = async () => {
try{
for await (const user of vonage.users.listAllUsers()) {
console.log(user);
}
} catch (error) {
console.error(error);
}
};
run();Run your code
Save this file to your machine and run it:
Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Add the following to build.gradle:
implementation 'com.vonage:server-sdk-kotlin:2.1.1'Create a file named ListUsers and add the following code to the main method:
val client = Vonage {
applicationId(VONAGE_APPLICATION_ID)
privateKeyPath(VONAGE_PRIVATE_KEY_PATH)
}Write the code
Add the following to the main method of the ListUsers file:
val users = client.users.list()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.users with the package containing ListUsers:
Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Add the following to build.gradle:
implementation 'com.vonage:server-sdk:9.3.1'Create a file named ListUsers 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 ListUsers file:
List<BaseUser> users = client.getUsersClient().listUsers();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.users with the package containing ListUsers:
Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
Install-Package VonageCreate a file named GetUsers.cs and add the following code:
using System;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Vonage;
using Vonage.Request;
using Vonage.Users.GetUsers;Add the following to GetUsers.cs:
var credentials = Credentials.FromAppIdAndPrivateKeyPath(VONAGE_APPLICATION_ID, VONAGE_PRIVATE_KEY_PATH);
var client = new VonageClient(credentials);Write the code
Add the following to GetUsers.cs:
var response = await client.UsersClient.GetUsersAsync(GetUsersRequest.Build().Create());Prerequisites
You will need to use an existing Application containing at least one User in order to see a list of a Users. See the Create Conversation code snippet for information on how to create an Application. See also the Create User code snippet on how to create a User.
pip install vonage python-dotenvWrite the code
Add the following to list-users.py:
from vonage import Auth, Vonage
client = Vonage(
Auth(
application_id=VONAGE_APPLICATION_ID,
private_key=VONAGE_PRIVATE_KEY,
)
)
users_list, next_page_cursor = client.users.list_users()
print(users_list)Run your code
Save this file to your machine and run it:
Try it out
When you run the code you will get a list of Users associated with an Application.