名前空間: microsoft.graph
ユーザーに対して新しい temporaryAccessPassAuthenticationMethod オブジェクトを作成します。 ユーザーは、指定された有効期間内に使用可能な一時アクセス パスを 1 つだけ持つことができます。 現在の一時アクセス パスが有効な間にユーザーが新しい一時アクセス パスを必要とする場合、管理者はユーザーの新しい一時アクセス パスを作成でき、以前の一時アクセス パスが削除され、新しい一時アクセス パスが作成されます。
この API は、次の国内クラウド展開で使用できます。
グローバル サービス |
米国政府機関 L4 |
米国政府機関 L5 (DOD) |
21Vianet が運営する中国 |
✅ |
✅ |
✅ |
❌ |
アクセス許可
この API の最小特権としてマークされているアクセス許可またはアクセス許可を選択します。
アプリで必要な場合にのみ、より高い特権のアクセス許可またはアクセス許可を使用します。 委任されたアクセス許可とアプリケーションのアクセス許可の詳細については、「アクセス許可の種類」を参照してください。 これらのアクセス許可の詳細については、「アクセス許可のリファレンス」を参照してください。
他のユーザーに対して動作するアクセス許可
アクセス許可の種類 |
最小特権アクセス許可 |
より高い特権のアクセス許可 |
委任 (職場または学校のアカウント) |
UserAuthenticationMethod.ReadWrite.All |
注意事項なし。 |
委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
サポートされていません。 |
アプリケーション |
UserAuthenticationMethod.ReadWrite.All |
注意事項なし。 |
重要
サインインしているユーザーが別のユーザーを操作している職場または学校アカウントで委任されたシナリオでは、サポートされているMicrosoft Entraロールまたはサポートされているロールのアクセス許可を持つカスタム ロールを割り当てる必要があります。 この操作では、次の最小特権ロールがサポートされています。
HTTP 要求
POST /users/{id | userPrincipalName}/authentication/temporaryAccessPassMethods
名前 |
説明 |
Authorization |
ベアラー {token}。 必須です。
認証と認可についての詳細をご覧ください。 |
Content-Type |
application/json. 必須です。 |
要求本文
要求本文で、 temporaryAccessPassAuthenticationMethod オブジェクトの JSON 表現を指定します。
次の表では、 temporaryAccessPassAuthenticationMethod を作成するときに使用できる省略可能なプロパティについて説明します。
プロパティ |
型 |
説明 |
isUsableOnce |
ブール値 |
省略可能。 パスが 1 回限りの使用に制限されているかどうかを判断します。
true 場合は、パスを 1 回使用できます。false 場合、そのパスは lifetimeInMinutes 設定内で複数回使用できます。 複数使用の一時アクセス パス (isUsableOnce = false ) は、 一時的なアクセス パス認証方法ポリシーによって許可されている場合にのみ作成し、サインインに使用できます。 |
lifetimeInMinutes |
Int32 |
省略可能。 作成時または startDateTime (設定されている場合) から開始する、temporaryAccessPass の有効期間 (分)。 10 から 43200 (30 日に相当) の間である必要があります。 指定しない場合、一時アクセス パス認証方法ポリシーの defaultLifetimeInMinutes 設定が適用されます。 |
startDateTime |
DateTimeOffset |
省略可能。 temporaryAccessPass が使用できるようになる日時。 指定しない場合は、一時アクセス パスを作成した直後に使用できます。 |
応答
成功した場合、このメソッドは応答コード 201 Created
と、応答本文に temporaryAccessPassAuthenticationMethod オブジェクトを返します。
例
要求
POST https://graph.microsoft.com/v1.0/users/071cc716-8147-4397-a5ba-b2105951cc0b/authentication/temporaryAccessPassMethods
Content-Type: application/json
{
"startDateTime": "2022-06-05T00:00:00.000Z",
"lifetimeInMinutes": 60,
"isUsableOnce": false
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new TemporaryAccessPassAuthenticationMethod
{
StartDateTime = DateTimeOffset.Parse("2022-06-05T00:00:00.000Z"),
LifetimeInMinutes = 60,
IsUsableOnce = false,
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Users["{user-id}"].Authentication.TemporaryAccessPassMethods.PostAsync(requestBody);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
mgc users authentication temporary-access-pass-methods create --user-id {user-id} --body '{\
"startDateTime": "2022-06-05T00:00:00.000Z",\
"lifetimeInMinutes": 60,\
"isUsableOnce": false\
}\
'
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
"time"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewTemporaryAccessPassAuthenticationMethod()
startDateTime , err := time.Parse(time.RFC3339, "2022-06-05T00:00:00.000Z")
requestBody.SetStartDateTime(&startDateTime)
lifetimeInMinutes := int32(60)
requestBody.SetLifetimeInMinutes(&lifetimeInMinutes)
isUsableOnce := false
requestBody.SetIsUsableOnce(&isUsableOnce)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
temporaryAccessPassMethods, err := graphClient.Users().ByUserId("user-id").Authentication().TemporaryAccessPassMethods().Post(context.Background(), requestBody, nil)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
TemporaryAccessPassAuthenticationMethod temporaryAccessPassAuthenticationMethod = new TemporaryAccessPassAuthenticationMethod();
OffsetDateTime startDateTime = OffsetDateTime.parse("2022-06-05T00:00:00.000Z");
temporaryAccessPassAuthenticationMethod.setStartDateTime(startDateTime);
temporaryAccessPassAuthenticationMethod.setLifetimeInMinutes(60);
temporaryAccessPassAuthenticationMethod.setIsUsableOnce(false);
TemporaryAccessPassAuthenticationMethod result = graphClient.users().byUserId("{user-id}").authentication().temporaryAccessPassMethods().post(temporaryAccessPassAuthenticationMethod);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const temporaryAccessPassAuthenticationMethod = {
startDateTime: '2022-06-05T00:00:00.000Z',
lifetimeInMinutes: 60,
isUsableOnce: false
};
await client.api('/users/071cc716-8147-4397-a5ba-b2105951cc0b/authentication/temporaryAccessPassMethods')
.post(temporaryAccessPassAuthenticationMethod);
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\TemporaryAccessPassAuthenticationMethod;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new TemporaryAccessPassAuthenticationMethod();
$requestBody->setStartDateTime(new \DateTime('2022-06-05T00:00:00.000Z'));
$requestBody->setLifetimeInMinutes(60);
$requestBody->setIsUsableOnce(false);
$result = $graphServiceClient->users()->byUserId('user-id')->authentication()->temporaryAccessPassMethods()->post($requestBody)->wait();
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
startDateTime = [System.DateTime]::Parse("2022-06-05T00:00:00.000Z")
lifetimeInMinutes = 60
isUsableOnce = $false
}
New-MgUserAuthenticationTemporaryAccessPassMethod -UserId $userId -BodyParameter $params
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.temporary_access_pass_authentication_method import TemporaryAccessPassAuthenticationMethod
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = TemporaryAccessPassAuthenticationMethod(
start_date_time = "2022-06-05T00:00:00.000Z",
lifetime_in_minutes = 60,
is_usable_once = False,
)
result = await graph_client.users.by_user_id('user-id').authentication.temporary_access_pass_methods.post(request_body)
プロジェクトに SDK を追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.temporaryAccessPassAuthenticationMethod",
"id": "6f1967b7-15e8-4935-ac26-d50770ed07a7",
"temporaryAccessPass": "+drkzqAD",
"createdDateTime": "2022-06-02T16:21:09.765173Z",
"startDateTime": "2022-06-05T00:00:00Z",
"lifetimeInMinutes": 60,
"isUsableOnce": false,
"isUsable": false,
"methodUsabilityReason": "NotYetValid"
}