我想知道发送电子邮件的用户的电子邮件地址。 在我的应用程序中,人们可以使用社交帐户(google/facebook/Microsoft)或本地帐户进行注册。 创建本地帐户时,我们使用电子邮件。
我找到了有关如何存储电子邮件的信息。 https://learn.microsoft.com/en-us/azure/active-directory-b2c/active-directory-b2c-reference-policies
Email address storage: An email address can be required as part of a user flow. If the user authenticates with a social identity provider, the email address is stored in the otherMails property. If a local account is based on a user name, then the email address is stored in a strong authentication detail property. If a local account is based on an email address, then the email address is stored in the signInNames property. The email address isn't guaranteed to be verified in any of these cases. A tenant administrator can disable email verification in the basic policies for local accounts. Even if email address verification is enabled, addresses aren't verified if they come from a social identity provider and they haven't been changed. Only the otherMails and signInNames properties are exposed through the Active Directory Graph API. The email address in the strong authentication detail property is not available
不知道为什么用户的“邮件”字段没有被使用...但使用 GraphApi:
我做了一个 GET:https://graph.microsoft.com/v1.0/Users ?$select=displayName,邮件,otherMails,signInNames
一些电子邮件出现在“mail”上,其他电子邮件出现在“otherMails”数组中,并且无法选择“singInNames”:( 不显示任何信息,一些我无法获取信息的用户也是如此关于电子邮件。
我该如何解决这个问题?仅使用Azure AD Graph而不是Microsoft Graph API,因为该API返回了signInNames?
有没有办法将电子邮件始终存储在同一属性上?或者至少我可以通过 Microsoft Graph API 访问一个?仅将自定义策略与声明转换一起使用?
最佳答案
在 Microsoft Graph API 中,您可以使用:
GET: https://graph.microsoft.com/v1.0/Users?$select=displayName,mail,identities,otherMails
您可以在身份集合中找到本地帐户的电子邮件。
在 Graph API 的 BETA 版本 (graph.microsoft.com/beta) 中,身份和 otherMails 属性也会在没有 $select 的情况下返回,而在 v1.0 版本中,只有在 $select 中指定时才会返回。
关于azure - 如何使用 Graph API 访问 B2C 用户的电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58345786/