Espacio de nombres: microsoft.graph
Importante
Las API de la versión /beta de Microsoft Graph están sujetas a cambios. No se admite el uso de estas API en aplicaciones de producción. Para determinar si una API está disponible en la versión 1.0, use el selector de Versión.
Actualice las propiedades de un objeto hardwareOathTokenAuthenticationMethodDevice . El token debe quitar la asignación.
Esta API está disponible en las siguientes implementaciones nacionales de nube.
| Servicio global |
Gobierno de EE. UU. L4 |
Us Government L5 (DOD) |
China operada por 21Vianet |
| ✅ |
❌ |
❌ |
❌ |
Permissions
Elija el permiso o los permisos marcados como con privilegios mínimos para esta API. Use un permiso o permisos con privilegios superiores solo si la aplicación lo requiere. Para obtener más información sobre los permisos delegados y de aplicación, consulte Tipos de permisos. Para obtener más información sobre estos permisos, consulte la referencia de permisos.
| Tipo de permiso |
Permisos con privilegios mínimos |
Permisos con privilegios más altos |
| Delegado (cuenta profesional o educativa) |
Policy.ReadWrite.AuthenticationMethod |
No disponible. |
| Delegado (cuenta personal de Microsoft) |
No admitida. |
No admitida. |
| Aplicación |
Policy.ReadWrite.AuthenticationMethod |
No disponible. |
Importante
En escenarios delegados con cuentas profesionales o educativas, al usuario que ha iniciado sesión se le debe asignar un rol de Microsoft Entra compatible o un rol personalizado con un permiso de rol admitido.
El administrador de directivas de autenticación es el rol con privilegios mínimos admitido para esta operación.
Solicitud HTTP
PATCH /directory/authenticationMethodDevices/hardwareOathDevices/{hardwareOathTokenAuthenticationMethodDeviceId}
| Nombre |
Descripción |
| Authorization |
{token} de portador. Obligatorio. Obtenga más información sobre la autenticación y la autorización. |
| Content-Type |
application/json. Obligatorio. |
Cuerpo de la solicitud
En el cuerpo de la solicitud, proporcione solo los valores de las propiedades que se van a actualizar. Las propiedades existentes que no se incluyen en el cuerpo de la solicitud mantienen sus valores anteriores o se recalculan en función de los cambios realizados en otros valores de propiedad.
En la tabla siguiente se especifican las propiedades que se pueden actualizar.
| Propiedad |
Tipo |
Descripción |
| manufacturer |
Cadena |
Nombre del fabricante del token de hardware. Opcional. |
| model |
Cadena |
Nombre del modelo del token de hardware. Opcional. |
| timeIntervalInSeconds |
Int32 |
Intervalo de actualización del código de verificación de 6 dígitos, en segundos. Los valores posibles son: 30 o 60. Opcional. |
| hashFunction |
hardwareOathTokenHashFunction |
Función hash del token de hardrware. Los valores posibles son: hmacsha1 o hmacsha256. El valor predeterminado es: hmacsha1. Opcional. |
| displayName |
Cadena |
Nombre que se puede proporcionar al token oath de hardware. Opcional. |
Respuesta
Si se ejecuta correctamente, este método devuelve un código de respuesta 204 No Content.
Ejemplos
Solicitud
En el ejemplo siguiente se muestra la solicitud.
PATCH https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices/{hardwareOathTokenAuthenticationMethodDeviceId}
Content-Type: application/json
{
"hashFunction": "hmacsha256"
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new HardwareOathTokenAuthenticationMethodDevice
{
HashFunction = HardwareOathTokenHashFunction.Hmacsha256,
};
// 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["{hardwareOathTokenAuthenticationMethodDevice-id}"].PatchAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewHardwareOathTokenAuthenticationMethodDevice()
hashFunction := graphmodels.HMACSHA256_HARDWAREOATHTOKENHASHFUNCTION
requestBody.SetHashFunction(&hashFunction)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
hardwareOathDevices, err := graphClient.Directory().AuthenticationMethodDevices().HardwareOathDevices().ByHardwareOathTokenAuthenticationMethodDeviceId("hardwareOathTokenAuthenticationMethodDevice-id").Patch(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDevice hardwareOathTokenAuthenticationMethodDevice = new HardwareOathTokenAuthenticationMethodDevice();
hardwareOathTokenAuthenticationMethodDevice.setHashFunction(HardwareOathTokenHashFunction.Hmacsha256);
HardwareOathTokenAuthenticationMethodDevice result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().byHardwareOathTokenAuthenticationMethodDeviceId("{hardwareOathTokenAuthenticationMethodDevice-id}").patch(hardwareOathTokenAuthenticationMethodDevice);
const options = {
authProvider,
};
const client = Client.init(options);
const hardwareOathTokenAuthenticationMethodDevice = {
hashFunction: 'hmacsha256'
};
await client.api('/directory/authenticationMethodDevices/hardwareOathDevices/{hardwareOathTokenAuthenticationMethodDeviceId}')
.version('beta')
.update(hardwareOathTokenAuthenticationMethodDevice);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\HardwareOathTokenAuthenticationMethodDevice;
use Microsoft\Graph\Beta\Generated\Models\HardwareOathTokenHashFunction;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new HardwareOathTokenAuthenticationMethodDevice();
$requestBody->setHashFunction(new HardwareOathTokenHashFunction('hmacsha256'));
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->byHardwareOathTokenAuthenticationMethodDeviceId('hardwareOathTokenAuthenticationMethodDevice-id')->patch($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
hashFunction = "hmacsha256"
}
Update-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice -HardwareOathTokenAuthenticationMethodDeviceId $hardwareOathTokenAuthenticationMethodDeviceId -BodyParameter $params
# 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(
hash_function = HardwareOathTokenHashFunction.Hmacsha256,
)
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.by_hardware_oath_token_authentication_method_device_id('hardwareOathTokenAuthenticationMethodDevice-id').patch(request_body)
Respuesta
En el ejemplo siguiente se muestra la respuesta.
HTTP/1.1 204 No Content