名前空間: microsoft.graph
重要
Microsoft Graph の /beta
バージョンの API は変更される可能性があります。 実稼働アプリケーションでこれらの API を使用することは、サポートされていません。 v1.0 で API を使用できるかどうかを確認するには、Version セレクターを使用します。
新しい hardwareOathTokenAuthenticationMethodDevice オブジェクトを 作成します。 この API では、次の 2 つのシナリオがサポートされています。
- ユーザーに割り当てずに新しいハードウェア トークンを作成します。 その後、 ユーザーに割り当てることができます。
- 同じ要求でハードウェア トークンを作成してユーザーに割り当てます。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
❌ |
❌ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
Policy.ReadWrite.AuthenticationMethod |
注意事項なし。 |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
Policy.ReadWrite.AuthenticationMethod |
注意事項なし。 |
重要
職場または学校のアカウントで委任されたアクセス許可を使用する場合、サインインしているユーザーは、適切なMicrosoft Entraロールまたは必要なアクセス許可を持つカスタム ロールを持っている必要があります。 この操作に必要な最小限の特権の組み込みロールは 、認証ポリシー管理者です。
1 つの要求でハードウェア OATH トークンを作成してユーザーに割り当てるには、サインインしているユーザーにも次のものが必要です。
-
UserAuthenticationMethod.ReadWrite.All 委任されたアクセス許可。
-
認証管理者 (管理者以外のユーザーにハードウェア トークンを割り当てるための最小特権ロール) または特権認証管理者 (管理者ユーザーにハードウェア トークンを割り当てるための最小特権ロール) ロール。
HTTP 要求
POST /directory/authenticationMethodDevices/hardwareOathDevices
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、 hardwareOathTokenAuthenticationMethodDevice オブジェクトの JSON 表現を指定します。
hardwareOathTokenAuthenticationMethodDevice を作成するときに、次のプロパティを指定できます。
プロパティ |
型 |
説明 |
シリアル番号 |
文字列 |
多くの場合、デバイスの背面にある特定のハードウェア トークンのシリアル番号。 必須です。 |
manufacturer |
文字列 |
ハードウェア トークンの製造元名。 必須です。 |
model |
文字列 |
ハードウェア トークンのモデル名。 必須です。 |
secretKey |
文字列 |
ベンダーによって提供される、特定のハードウェア トークンの秘密キー。 必須です。 |
timeIntervalInSeconds |
Int32 |
6 桁の検証コードの更新間隔 (秒単位)。 使用可能な値は 30 または 60 です。 必須です。 |
hashFunction |
hardwareOathTokenHashFunction |
ハードウェア トークンのハッシュ関数。 使用可能な値: hmacsha1 、hmacsha256 。 既定値は hmacsha1 です。 省略可能。 |
assignTo |
identity |
トークンをユーザーに直接割り当てる場合は、ユーザー ID。 省略可能。 |
displayName |
文字列 |
ハードウェア OATH トークンに指定できる名前。 省略可能。 |
応答
成功した場合、このメソッドは応答コード 201 Created
と、応答本文の hardwareOathTokenAuthenticationMethodDevice オブジェクトを返します。
例
例 1: ユーザー割り当てなしでトークンを作成する
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices
Content-Type: application/json
{
"displayName": "Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
"timeIntervalInSeconds": 30,
"hashFunction": "hmacsha1"
}
// 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);
mgc-beta directory authentication-method-devices hardware-oath-devices create --body '{\
"displayName": "Token 1",\
"serialNumber": "TOTP123456",\
"manufacturer": "Contoso",\
"model": "Hardware Token 1000",\
"secretKey": "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",\
"timeIntervalInSeconds": 30,\
"hashFunction": "hmacsha1"\
}\
'
// 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()
displayName := "Token 1"
requestBody.SetDisplayName(&displayName)
serialNumber := "TOTP123456"
requestBody.SetSerialNumber(&serialNumber)
manufacturer := "Contoso"
requestBody.SetManufacturer(&manufacturer)
model := "Hardware Token 1000"
requestBody.SetModel(&model)
secretKey := "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB"
requestBody.SetSecretKey(&secretKey)
timeIntervalInSeconds := int32(30)
requestBody.SetTimeIntervalInSeconds(&timeIntervalInSeconds)
hashFunction := graphmodels.HMACSHA1_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().Post(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.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);
const options = {
authProvider,
};
const client = Client.init(options);
const hardwareOathTokenAuthenticationMethodDevice = {
displayName: 'Token 1',
serialNumber: 'TOTP123456',
manufacturer: 'Contoso',
model: 'Hardware Token 1000',
secretKey: '6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB',
timeIntervalInSeconds: 30,
hashFunction: 'hmacsha1'
};
await client.api('/directory/authenticationMethodDevices/hardwareOathDevices')
.version('beta')
.post(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->setDisplayName('Token 1');
$requestBody->setSerialNumber('TOTP123456');
$requestBody->setManufacturer('Contoso');
$requestBody->setModel('Hardware Token 1000');
$requestBody->setSecretKey('6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB');
$requestBody->setTimeIntervalInSeconds(30);
$requestBody->setHashFunction(new HardwareOathTokenHashFunction('hmacsha1'));
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
displayName = "Token 1"
serialNumber = "TOTP123456"
manufacturer = "Contoso"
model = "Hardware Token 1000"
secretKey = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB"
timeIntervalInSeconds = 30
hashFunction = "hmacsha1"
}
New-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice -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(
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)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.hardwareOathTokenAuthenticationMethodDevice",
"id": "9b037532-f999-1ed9-13fd-849ffb995e11",
"displayName": "Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "available",
"lastUsedDateTime": null,
"assignedTo": null,
"hashFunction": "hmacsha1"
}
例 2: トークンを作成してユーザーに割り当てる
要求
次の例は要求を示しています。
POST https://graph.microsoft.com/beta/directory/authenticationMethodDevices/hardwareOathDevices
Content-Type: application/json
{
"displayName": "Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",
"timeIntervalInSeconds": 30,
"hashFunction": "hmacsha1",
"assignTo": {
"id": "0cadbf92-####-####-####-############"
}
}
// 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);
mgc-beta directory authentication-method-devices hardware-oath-devices create --body '{\
"displayName": "Token 1",\
"serialNumber": "TOTP123456",\
"manufacturer": "Contoso",\
"model": "Hardware Token 1000",\
"secretKey": "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB",\
"timeIntervalInSeconds": 30,\
"hashFunction": "hmacsha1",\
"assignTo": {\
"id": "0cadbf92-####-####-####-############"\
}\
}\
'
// 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()
displayName := "Token 1"
requestBody.SetDisplayName(&displayName)
serialNumber := "TOTP123456"
requestBody.SetSerialNumber(&serialNumber)
manufacturer := "Contoso"
requestBody.SetManufacturer(&manufacturer)
model := "Hardware Token 1000"
requestBody.SetModel(&model)
secretKey := "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB"
requestBody.SetSecretKey(&secretKey)
timeIntervalInSeconds := int32(30)
requestBody.SetTimeIntervalInSeconds(&timeIntervalInSeconds)
hashFunction := graphmodels.HMACSHA1_HARDWAREOATHTOKENHASHFUNCTION
requestBody.SetHashFunction(&hashFunction)
assignTo := graphmodels.NewUser()
id := "0cadbf92-####-####-####-############"
assignTo.SetId(&id)
requestBody.SetAssignTo(assignTo)
// 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().Post(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.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);
const options = {
authProvider,
};
const client = Client.init(options);
const hardwareOathTokenAuthenticationMethodDevice = {
displayName: 'Token 1',
serialNumber: 'TOTP123456',
manufacturer: 'Contoso',
model: 'Hardware Token 1000',
secretKey: '6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB',
timeIntervalInSeconds: 30,
hashFunction: 'hmacsha1',
assignTo: {
id: '0cadbf92-####-####-####-############'
}
};
await client.api('/directory/authenticationMethodDevices/hardwareOathDevices')
.version('beta')
.post(hardwareOathTokenAuthenticationMethodDevice);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\HardwareOathTokenAuthenticationMethodDevice;
use Microsoft\Graph\Beta\Generated\Models\HardwareOathTokenHashFunction;
use Microsoft\Graph\Beta\Generated\Models\User;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new HardwareOathTokenAuthenticationMethodDevice();
$requestBody->setDisplayName('Token 1');
$requestBody->setSerialNumber('TOTP123456');
$requestBody->setManufacturer('Contoso');
$requestBody->setModel('Hardware Token 1000');
$requestBody->setSecretKey('6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB');
$requestBody->setTimeIntervalInSeconds(30);
$requestBody->setHashFunction(new HardwareOathTokenHashFunction('hmacsha1'));
$assignTo = new User();
$assignTo->setId('0cadbf92-####-####-####-############');
$requestBody->setAssignTo($assignTo);
$result = $graphServiceClient->directory()->authenticationMethodDevices()->hardwareOathDevices()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.DirectoryManagement
$params = @{
displayName = "Token 1"
serialNumber = "TOTP123456"
manufacturer = "Contoso"
model = "Hardware Token 1000"
secretKey = "6PJ4UKIW33NNXYZAEHQNFUFTZF7WFTFB"
timeIntervalInSeconds = 30
hashFunction = "hmacsha1"
assignTo = @{
id = "0cadbf92-####-####-####-############"
}
}
New-MgBetaDirectoryAuthenticationMethodDeviceHardwareOathDevice -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
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)
応答
次の例は応答を示しています。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.hardwareOathTokenAuthenticationMethodDevice",
"id": "9b037532-f999-1ed9-13fd-849ffb995e11",
"displayName": "Token 1",
"serialNumber": "TOTP123456",
"manufacturer": "Contoso",
"model": "Hardware Token 1000",
"secretKey": null,
"timeIntervalInSeconds": 30,
"status": "assigned",
"lastUsedDateTime": null,
"assignedTo": null,
"hashFunction": "hmacsha1",
"assignedTo": {
"id": "0cadbf92-####-####-####-############",
"displayName": "Amy Masters"
}
}