Namespace: microsoft.graph
Important
APIs under the /beta
version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported. To determine whether an API is available in v1.0, use the Version selector.
List all hardware OATH tokens in the directory.
This API is available in the following national cloud deployments.
Global service |
US Government L4 |
US Government L5 (DOD) |
China operated by 21Vianet |
✅ |
❌ |
❌ |
❌ |
Permissions
Choose the permission or permissions marked as least privileged for this API. Use a higher privileged permission or permissions only if your app requires it. For details about delegated and application permissions, see Permission types. To learn more about these permissions, see the permissions reference.
Permission type |
Least privileged permissions |
Higher privileged permissions |
Delegated (work or school account) |
Policy.Read.All |
Policy.ReadWrite.AuthenticationMethod |
Delegated (personal Microsoft account) |
Not supported. |
Not supported. |
Application |
Policy.Read.All |
Policy.ReadWrite.AuthenticationMethod |
Important
In delegated scenarios with work or school accounts, the signed-in user must be assigned a supported Microsoft Entra role or a custom role with a supported role permission. The following least privileged roles are supported for this operation.
- Global Reader
- Authentication Policy Administrator
HTTP request
GET /directory/authenticationMethodDevices/hardwareOathDevices
Optional query parameters
This method supports $select
, $filter
(eq
) and $top
OData query parameters to help customize the response. For general information, see OData query parameters.
Request body
Don't supply a request body for this method.
Response
If successful, this method returns a 200 OK
response code and a collection of hardwareOathTokenAuthenticationMethodDevice objects in the response body.
Examples
Example 1: List all tokens in the inventory
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices
// Code snippets are only available for the latest version. Current version is 5.x
// 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.GetAsync();
mgc-beta directory authentication-method-devices hardware-oath-devices list
// 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"
//other-imports
)
// 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().Get(context.Background(), nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDeviceCollectionResponse result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().get();
const options = {
authProvider,
};
const client = Client.init(options);
let hardwareOathDevices = await client.api('/directory/authenticationMethodDevices/hardwareOathDevices')
.version('beta')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->get()->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.get()
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.hardwareOathAuthenticationMethod",
"id": "aad49556-####-####-####-############",
"device": {
"id": "aad49556-####-####-####-############",
"displayName": "Amy Masters Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "activated",
"hashFunction": "hmacsha1",
"assignedTo": {
"id": "0cadbf92-####-####-####-############",
"displayName": "Amy Masters"
}
}
},
{
"@odata.type": "#microsoft.graph.hardwareOathAuthenticationMethod",
"id": "3dee0e53-####-####-####-############",
"device": {
"id": "3dee0e53-####-####-####-############",
"displayName": "Amy Masters Token 2",
"serialNumber": "TOTP654321",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "assigned",
"hashFunction": "hmacsha1",
"assignedTo": {
"id": "0cadbf92-####-####-####-############",
"displayName": "Amy Masters"
}
}
}
]
}
Example 2: List all tokens in the inventory, filtered on status
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices?$filter=status eq 'activated'
// Code snippets are only available for the latest version. Current version is 5.x
// 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.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "status eq 'activated'";
});
mgc-beta directory authentication-method-devices hardware-oath-devices list --filter "status eq 'activated'"
// 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"
graphdirectory "github.com/microsoftgraph/msgraph-beta-sdk-go/directory"
//other-imports
)
requestFilter := "status eq 'activated'"
requestParameters := &graphdirectory.AuthenticationMethodDevicesHardwareOathDevicesRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphdirectory.AuthenticationMethodDevicesHardwareOathDevicesRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// 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().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDeviceCollectionResponse result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "status eq 'activated'";
});
const options = {
authProvider,
};
const client = Client.init(options);
let hardwareOathDevices = await client.api('/directory/authenticationMethodDevices/hardwareOathDevices')
.version('beta')
.filter('status eq \'activated\'')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Directory\AuthenticationMethodDevices\HardwareOathDevices\HardwareOathDevicesRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new HardwareOathDevicesRequestBuilderGetRequestConfiguration();
$queryParameters = HardwareOathDevicesRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "status eq 'activated'";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice -Filter "status eq 'activated'"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.directory.authentication_method_devices.hardware_oath_devices.hardware_oath_devices_request_builder import HardwareOathDevicesRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = HardwareOathDevicesRequestBuilder.HardwareOathDevicesRequestBuilderGetQueryParameters(
filter = "status eq 'activated'",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.get(request_configuration = request_configuration)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.hardwareOathAuthenticationMethod",
"id": "3dee0e53-####-####-####-############",
"device": {
"id": "3dee0e53-####-####-####-############",
"displayName": "Amy Masters Token 2",
"serialNumber": "TOTP654321",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "assigned",
"hashFunction": "hmacsha1",
"assignedTo": {
"id": "0cadbf92-####-####-####-############",
"displayName": "Amy Masters"
}
}
}
]
}
Example 3: Find a specific token by serial number
Request
The following example shows a request.
GET https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices?$filter=serialNumber eq 'TOTP123456'
// Code snippets are only available for the latest version. Current version is 5.x
// 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.GetAsync((requestConfiguration) =>
{
requestConfiguration.QueryParameters.Filter = "serialNumber eq 'TOTP123456'";
});
mgc-beta directory authentication-method-devices hardware-oath-devices list --filter "serialNumber eq 'TOTP123456'"
// 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"
graphdirectory "github.com/microsoftgraph/msgraph-beta-sdk-go/directory"
//other-imports
)
requestFilter := "serialNumber eq 'TOTP123456'"
requestParameters := &graphdirectory.AuthenticationMethodDevicesHardwareOathDevicesRequestBuilderGetQueryParameters{
Filter: &requestFilter,
}
configuration := &graphdirectory.AuthenticationMethodDevicesHardwareOathDevicesRequestBuilderGetRequestConfiguration{
QueryParameters: requestParameters,
}
// 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().Get(context.Background(), configuration)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
HardwareOathTokenAuthenticationMethodDeviceCollectionResponse result = graphClient.directory().authenticationMethodDevices().hardwareOathDevices().get(requestConfiguration -> {
requestConfiguration.queryParameters.filter = "serialNumber eq 'TOTP123456'";
});
const options = {
authProvider,
};
const client = Client.init(options);
let hardwareOathDevices = await client.api('/directory/authenticationMethodDevices/hardwareOathDevices')
.version('beta')
.filter('serialNumber eq \'TOTP123456\'')
.get();
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Directory\AuthenticationMethodDevices\HardwareOathDevices\HardwareOathDevicesRequestBuilderGetRequestConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestConfiguration = new HardwareOathDevicesRequestBuilderGetRequestConfiguration();
$queryParameters = HardwareOathDevicesRequestBuilderGetRequestConfiguration::createQueryParameters();
$queryParameters->filter = "serialNumber eq 'TOTP123456'";
$requestConfiguration->queryParameters = $queryParameters;
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->get($requestConfiguration)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
Get-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice -Filter "serialNumber eq 'TOTP123456'"
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.directory.authentication_method_devices.hardware_oath_devices.hardware_oath_devices_request_builder import HardwareOathDevicesRequestBuilder
from kiota_abstractions.base_request_configuration import RequestConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
query_params = HardwareOathDevicesRequestBuilder.HardwareOathDevicesRequestBuilderGetQueryParameters(
filter = "serialNumber eq 'TOTP123456'",
)
request_configuration = RequestConfiguration(
query_parameters = query_params,
)
result = await graph_client.directory.authentication_method_devices.hardware_oath_devices.get(request_configuration = request_configuration)
Response
The following example shows the response.
Note: The response object shown here might be shortened for readability.
HTTP/1.1 200 OK
Content-Type: application/json
{
"value": [
{
"@odata.type": "#microsoft.graph.hardwareOathAuthenticationMethod",
"id": "aad49556-####-####-####-############",
"device": {
"id": "aad49556-####-####-####-############",
"displayName": "Amy Masters Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "activated",
"hashFunction": "hmacsha1",
"assignedTo": {
"id": "0cadbf92-####-####-####-############",
"displayName": "Amy Masters"
}
}
}
]
}