创建 emailAuthenticationMethodCreate emailAuthenticationMethod

命名空间:microsoft.graphNamespace: microsoft.graph

重要

Microsoft Graph /beta 中版本下的 API 可能会更改。APIs under the /beta version in Microsoft Graph are subject to change. 不支持在生产应用程序中使用这些 API。Use of these APIs in production applications is not supported. 若要确定 API 在 v1.0 中是否可用,请使用 版本选择 器。To determine whether an API is available in v1.0, use the Version selector.

设置用户 的电子邮件AuthenticationMethod 对象。Set a user's emailAuthenticationMethod object. 电子邮件身份验证是一种自助服务密码重置方法。Email authentication is a self-service password reset method. 用户可能只有一种电子邮件身份验证方法。A user may only have one email authentication method.

PermissionsPermissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限One of the following permissions is required to call this API. To learn more, including how to choose permissions, see Permissions.

权限类型Permission type 自操作权限 (权限从最低到最特权) Permissions acting on self (from least to most privileged) 对他人 (权限从最低到最特权) Permissions acting on others (from least to most privileged)
委派(工作或学校帐户)Delegated (work or school account) UserAuthenticationMethod.ReadWriteUserAuthenticationMethod.ReadWrite UserAuthenticationMethod.ReadWrite.AllUserAuthenticationMethod.ReadWrite.All
委派(个人 Microsoft 帐户)Delegated (personal Microsoft account) 不支持。Not supported. 不支持。Not supported.
ApplicationApplication 不适用。Not applicable. UserAuthenticationMethod.ReadWrite.AllUserAuthenticationMethod.ReadWrite.All

对于管理员正在操作其他用户的委派方案,管理员需要以下角色之 For delegated scenarios where an admin is acting on another user, the admin needs one of the following roles:

  • 全局管理员Global admin
  • 特权身份验证管理员Privileged authentication admin
  • 身份验证管理员Authentication admin

HTTP 请求HTTP request

POST /users/{id | userPrincipalName}/authentication/emailMethods

请求标头Request headers

名称Name 说明Description
AuthorizationAuthorization Bearer {token}。必需。Bearer {token}. Required.
Content-TypeContent-Type application/json. Required.application/json. Required.

请求正文Request body

在请求正文中,提供 emailAuthenticationMethod 对象的 JSON 表示形式以及所需的电子邮件地址。In the request body, supply a JSON representation of the emailAuthenticationMethod object with the desired email address.

下表显示创建 emailAuthenticationMethod 时所需的属性The following table shows the properties that are required when you create the emailAuthenticationMethod.

属性Property 类型Type 说明Description
emailAddressemailAddress StringString 电子邮件地址Email address

响应Response

如果成功,此方法在响应正文中返回响应代码和 201 Created 新的 emailAuthenticationMethod 对象。If successful, this method returns a 201 Created response code and a new emailAuthenticationMethod object in the response body.

示例Examples

请求Request

POST https://graph.microsoft.com/beta/users/kim@contoso.com/authentication/emailMethods
Content-Type: application/json

{
  "emailAddress": "kim@contoso.com"
}

响应Response

下面展示了示例响应。The following is an example of the response.

注意: 为了提高可读性,可能缩短了此处显示的响应对象。Note: The response object shown here might be shortened for readability.

HTTP/1.1 200 OK
Content-type: application/json
Content-length: 491

{
  "id": "3ddfcfc8-9383-446f-83cc-3ab9be4be18f",
  "emailAddress": "kim@contoso.com"
}