// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new HardwareOathTokenAuthenticationMethodDevice
{
DisplayName = "Token 1",
SerialNumber = "TOTP123456",
Manufacturer = "Contoso",
Model = "Hardware Token 1000",
SecretKey = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
TimeIntervalInSeconds = 30,
HashFunction = HardwareOathTokenHashFunction.Hmacsha1,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.AuthenticationMethodDevices.HardwareOathDevices.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDevice hardwareOathTokenAuthenticationMethodDevice = new HardwareOathTokenAuthenticationMethodDevice();
hardwareOathTokenAuthenticationMethodDevice.setDisplayName("Token 1");
hardwareOathTokenAuthenticationMethodDevice.setSerialNumber("TOTP123456");
hardwareOathTokenAuthenticationMethodDevice.setManufacturer("Contoso");
hardwareOathTokenAuthenticationMethodDevice.setModel("Hardware Token 1000");
hardwareOathTokenAuthenticationMethodDevice.setSecretKey("6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB");
hardwareOathTokenAuthenticationMethodDevice.setTimeIntervalInSeconds(30);
hardwareOathTokenAuthenticationMethodDevice.setHashFunction(HardwareOathTokenHashFunction.Hmacsha1);
HardwareOathTokenAuthenticationMethodDevice result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().post(hardwareOathTokenAuthenticationMethodDevice);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.hardware_oath_token_authentication_method_device import HardwareOathTokenAuthenticationMethodDevice
from msgraph_beta.generated.models.hardware_oath_token_hash_function import HardwareOathTokenHashFunction
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = HardwareOathTokenAuthenticationMethodDevice(
display_name = "Token 1",
serial_number = "TOTP123456",
manufacturer = "Contoso",
model = "Hardware Token 1000",
secret_key = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
time_interval_in_seconds = 30,
hash_function = HardwareOathTokenHashFunction.Hmacsha1,
)
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.post(request_body)
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new HardwareOathTokenAuthenticationMethodDevice
{
DisplayName = "Token 1",
SerialNumber = "TOTP123456",
Manufacturer = "Contoso",
Model = "Hardware Token 1000",
SecretKey = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
TimeIntervalInSeconds = 30,
HashFunction = HardwareOathTokenHashFunction.Hmacsha1,
AssignTo = new User
{
Id = "0cadbf92-####-####-####-############",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Directory.AuthenticationMethodDevices.HardwareOathDevices.PostAsync(requestBody);
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDevice hardwareOathTokenAuthenticationMethodDevice = new HardwareOathTokenAuthenticationMethodDevice();
hardwareOathTokenAuthenticationMethodDevice.setDisplayName("Token 1");
hardwareOathTokenAuthenticationMethodDevice.setSerialNumber("TOTP123456");
hardwareOathTokenAuthenticationMethodDevice.setManufacturer("Contoso");
hardwareOathTokenAuthenticationMethodDevice.setModel("Hardware Token 1000");
hardwareOathTokenAuthenticationMethodDevice.setSecretKey("6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB");
hardwareOathTokenAuthenticationMethodDevice.setTimeIntervalInSeconds(30);
hardwareOathTokenAuthenticationMethodDevice.setHashFunction(HardwareOathTokenHashFunction.Hmacsha1);
User assignTo = new User();
assignTo.setId("0cadbf92-####-####-####-############");
hardwareOathTokenAuthenticationMethodDevice.setAssignTo(assignTo);
HardwareOathTokenAuthenticationMethodDevice result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().post(hardwareOathTokenAuthenticationMethodDevice);
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.hardware_oath_token_authentication_method_device import HardwareOathTokenAuthenticationMethodDevice
from msgraph_beta.generated.models.hardware_oath_token_hash_function import HardwareOathTokenHashFunction
from msgraph_beta.generated.models.user import User
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = HardwareOathTokenAuthenticationMethodDevice(
display_name = "Token 1",
serial_number = "TOTP123456",
manufacturer = "Contoso",
model = "Hardware Token 1000",
secret_key = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
time_interval_in_seconds = 30,
hash_function = HardwareOathTokenHashFunction.Hmacsha1,
assign_to = User(
id = "0cadbf92-####-####-####-############",
),
)
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.post(request_body)