更新 smsAuthenticationMethodConfiguration
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新 smsAuthenticationMethodConfiguration 对象的属性,该对象表示 Azure AD 租户的文本消息身份验证方法策略。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
Policy.ReadWrite.AuthenticationMethod
委派(个人 Microsoft 帐户)
不支持。
应用程序
Policy.ReadWrite.AuthenticationMethod
对于委派方案,管理员需要以下 Azure AD 角色 之一:
HTTP 请求
PATCH /policies/authenticationMethodsPolicy/authenticationMethodConfigurations/sms
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,使用应更新的字段值提供 smsAuthenticationMethodConfiguration 对象的 JSON 表示形式。 请求正文中不包括的现有属性将保留其以前的值,或根据对其他属性值的更改重新计算。 为了获得最佳性能,请勿加入尚未更改的现有值。
下表显示了更新 smsAuthenticationMethodConfiguration 对象时所需的属性。
属性
类型
说明
id
String
身份验证方法策略标识符。
state
authenticationMethodState
可取值为:enabled、disabled。
注意: @odata.type具有值的#microsoft.graph.smsAuthenticationMethodConfiguration属性必须包含在正文中。
响应
如果成功,此方法在响应正文中返回 200 OK 响应代码和更新 的 smsAuthenticationMethodConfiguration 对象。
示例
请求
PATCH https://graph.microsoft.com/beta/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/sms
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.smsAuthenticationMethodConfiguration",
"id": "Sms",
"state": "enabled"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var authenticationMethodConfiguration = new SmsAuthenticationMethodConfiguration
{
Id = "Sms",
State = AuthenticationMethodState.Enabled
};
await graphClient.Policies.AuthenticationMethodsPolicy.AuthenticationMethodConfigurations["{authenticationMethodConfiguration-id}"]
.Request()
.UpdateAsync(authenticationMethodConfiguration);
const options = {
authProvider,
};
const client = Client.init(options);
const authenticationMethodConfiguration = {
'@odata.type': '#microsoft.graph.smsAuthenticationMethodConfiguration',
id: 'Sms',
state: 'enabled'
};
await client.api('/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/sms')
.version('beta')
.update(authenticationMethodConfiguration);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/policies/authenticationMethodsPolicy/authenticationMethodConfigurations/sms"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphAuthenticationMethodConfiguration *authenticationMethodConfiguration = [[MSGraphAuthenticationMethodConfiguration alloc] init];
[authenticationMethodConfiguration setId:@"Sms"];
[authenticationMethodConfiguration setState: [MSGraphAuthenticationMethodState enabled]];
NSError *error;
NSData *authenticationMethodConfigurationData = [authenticationMethodConfiguration getSerializedDataWithError:&error];
[urlRequest setHTTPBody:authenticationMethodConfigurationData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SmsAuthenticationMethodConfiguration authenticationMethodConfiguration = new SmsAuthenticationMethodConfiguration();
authenticationMethodConfiguration.id = "Sms";
authenticationMethodConfiguration.state = AuthenticationMethodState.ENABLED;
graphClient.policies().authenticationMethodsPolicy().authenticationMethodConfigurations("sms")
.buildRequest()
.patch(authenticationMethodConfiguration);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewAuthenticationMethodConfiguration()
id := "Sms"
requestBody.SetId(&id)
state := "enabled"
requestBody.SetState(&state)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.smsAuthenticationMethodConfiguration",
}
authenticationMethodConfigurationId := "authenticationMethodConfiguration-id"
graphClient.Policies().AuthenticationMethodsPolicy().AuthenticationMethodConfigurationsById(&authenticationMethodConfigurationId).Patch(requestBody)
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.smsAuthenticationMethodConfiguration"
Id = "Sms"
State = "enabled"
}
Update-MgPolicyAuthenticationMethodPolicyAuthenticationMethodConfiguration -AuthenticationMethodConfigurationId $authenticationMethodConfigurationId -BodyParameter $params
响应
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 200 OK
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.smsAuthenticationMethodConfiguration",
"id": "713980c7-80c7-7139-c780-3971c7803971",
"state": "String"
}