更新 b2cAuthenticationMethodsPolicy
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 b2cAuthenticationMethodsPolicy 对象的属性。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限。
| 权限类型 |
权限 |
| 委派(工作或学校帐户) |
Policy.ReadWrite.AuthenticationMethod |
| 委派(个人 Microsoft 帐户) |
Policy.ReadWrite.AuthenticationMethod |
| 应用程序 |
Policy.ReadWrite.AuthenticationMethod |
HTTP 请求
PATCH /policies/b2cAuthenticationMethodsPolicy
| 名称 |
说明 |
| Authorization |
Bearer {token}。必需。 |
| Content-Type |
application/json. Required. |
请求正文
在请求正文中,提供 JSON 表示形式的 b2cAuthenticationMethodsPolicy 对象。
下表显示了更新 b2cAuthenticationMethodsPolicy 时所需的属性。
| 属性 |
类型 |
Description |
| isEmailPasswordAuthenticationEnabled |
布尔值 |
如果启用了电子邮件和密码身份验证方法,租户管理员可以使用电子邮件配置本地帐户。 |
| isUserNameAuthenticationEnabled |
布尔值 |
如果启用了用户名和密码身份验证方法,租户管理员可以使用用户名配置本地帐户。 |
| isPhoneOneTimePasswordAuthenticationEnabled |
布尔值 |
如果已启用电话号码和一次性密码身份验证方法,则租户管理员可以使用电话号码配置本地帐户。 |
响应
如果成功,此方法将返回 204 No Content 响应代码和空响应正文。
示例
请求
下面展示了示例请求。
PATCH https://graph.microsoft.com/beta/policies/b2cAuthenticationMethodsPolicy
{
"isEmailPasswordAuthenticationEnabled": false,
"isUserNameAuthenticationEnabled": true,
"isPhoneOneTimePasswordAuthenticationEnabled": true
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var b2cAuthenticationMethodsPolicy = new B2cAuthenticationMethodsPolicy
{
IsEmailPasswordAuthenticationEnabled = false,
IsUserNameAuthenticationEnabled = true,
IsPhoneOneTimePasswordAuthenticationEnabled = true
};
await graphClient.Policies.B2cAuthenticationMethodsPolicy
.Request()
.UpdateAsync(b2cAuthenticationMethodsPolicy);
const options = {
authProvider,
};
const client = Client.init(options);
const b2cAuthenticationMethodsPolicy = {
isEmailPasswordAuthenticationEnabled: false,
isUserNameAuthenticationEnabled: true,
isPhoneOneTimePasswordAuthenticationEnabled: true
};
await client.api('/policies/b2cAuthenticationMethodsPolicy')
.version('beta')
.update(b2cAuthenticationMethodsPolicy);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/policies/b2cAuthenticationMethodsPolicy"]]];
[urlRequest setHTTPMethod:@"PATCH"];
MSGraphB2cAuthenticationMethodsPolicy *b2cAuthenticationMethodsPolicy = [[MSGraphB2cAuthenticationMethodsPolicy alloc] init];
[b2cAuthenticationMethodsPolicy setIsEmailPasswordAuthenticationEnabled: false];
[b2cAuthenticationMethodsPolicy setIsUserNameAuthenticationEnabled: true];
[b2cAuthenticationMethodsPolicy setIsPhoneOneTimePasswordAuthenticationEnabled: true];
NSError *error;
NSData *b2cAuthenticationMethodsPolicyData = [b2cAuthenticationMethodsPolicy getSerializedDataWithError:&error];
[urlRequest setHTTPBody:b2cAuthenticationMethodsPolicyData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
B2cAuthenticationMethodsPolicy b2cAuthenticationMethodsPolicy = new B2cAuthenticationMethodsPolicy();
b2cAuthenticationMethodsPolicy.isEmailPasswordAuthenticationEnabled = false;
b2cAuthenticationMethodsPolicy.isUserNameAuthenticationEnabled = true;
b2cAuthenticationMethodsPolicy.isPhoneOneTimePasswordAuthenticationEnabled = true;
graphClient.policies().b2cAuthenticationMethodsPolicy()
.buildRequest()
.patch(b2cAuthenticationMethodsPolicy);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewB2cAuthenticationMethodsPolicy()
isEmailPasswordAuthenticationEnabled := false
requestBody.SetIsEmailPasswordAuthenticationEnabled(&isEmailPasswordAuthenticationEnabled)
isUserNameAuthenticationEnabled := true
requestBody.SetIsUserNameAuthenticationEnabled(&isUserNameAuthenticationEnabled)
isPhoneOneTimePasswordAuthenticationEnabled := true
requestBody.SetIsPhoneOneTimePasswordAuthenticationEnabled(&isPhoneOneTimePasswordAuthenticationEnabled)
graphClient.Policies().B2cAuthenticationMethodsPolicy().Patch(requestBody)
响应
下面展示了示例响应。
HTTP/1.1 204 NO CONTENT