Créer un matérielOathTokenAuthenticationMethodDevice
Article
Espace de noms: microsoft.graph
Importante
Les API sous la version /beta dans Microsoft Graph sont susceptibles d’être modifiées. L’utilisation de ces API dans des applications de production n’est pas prise en charge. Pour déterminer si une API est disponible dans v1.0, utilisez le sélecteur Version .
Créez un objet hardwareOathTokenAuthenticationMethodDevice. Vous pouvez éventuellement créer et attribuer à un utilisateur dans la même demande ; Ou attribuer à un utilisateur via l’API d’attribution .
Dans les scénarios délégués avec des comptes professionnels ou scolaires, l’utilisateur connecté doit se voir attribuer un rôle Microsoft Entra pris en charge ou un rôle personnalisé avec une autorisation de rôle prise en charge.
Administrateur de stratégie d’authentification est le rôle le moins privilégié pris en charge pour cette opération.
Requête HTTP
POST /directory/authenticationMethodDevices/hardwareOathDevices
// 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)