[英]Microsoft Graph SDK not returning Custom attributes values of Azure AD B2C Users
I have added a new custom attribute and selected it in the Application claims of the signup-signin userflow.我添加了一个新的自定义属性,并在注册登录用户流的应用程序声明中选择了它。
So I created a new user and set a value for this custom attribute during the signup.所以我创建了一个新用户并在注册期间为这个自定义属性设置了一个值。 When I sign in with the user, the attribute is persisted in the token claims so I can get the value from the token.
当我与用户登录时,该属性会保留在令牌声明中,因此我可以从令牌中获取值。
So now I need to get it using Graph SDK, I am trying to do so using the following code which is inspired from this Microsoft Docs所以现在我需要使用 Graph SDK 来获取它,我正在尝试使用受此Microsoft Docs启发的以下代码
ClientCredentialProvider authProvider = new ClientCredentialProvider(confidentialClientApplication);
GraphServiceClient graphClient = new GraphServiceClient(authProvider);
var customAttribute = $"extension_clientIdWithoutDash_CustomAttributeName";
var result = await graphClient.Users["2d7f1b9d-b57c-4a1a-bf56-fa27a952bacf"]
.Request()
.Select(customAttribute)
.GetAsync();
var customAttributsAreHere = result.AdditionalData;
But when I check the response the custom attribute is not there.但是当我检查响应时,自定义属性不存在。 Default attributes are there if I include them in the select.
如果我将它们包含在 select 中,则存在默认属性。 Any clue what may be the reason?
任何线索可能是什么原因?
This is the Client Id I am using when requesting the custom attribute as "extension_clientId_customattribute".这是我在将自定义属性请求为“extension_clientId_customattribute”时使用的客户端 ID。 (but without the hyphens)
(但没有连字符)
You must use client id of the application created with your extensions (depends on how extension was created).您必须使用使用扩展创建的应用程序的客户端 ID(取决于扩展的创建方式)。 Please refer this article :
请参考这篇文章:
Extension attributes can only be registered on an application object, even though they might contain data for a user.
扩展属性只能在应用程序 object 上注册,即使它们可能包含用户的数据。 The extension attribute is attached to the application called b2c-extensions-app .
扩展属性附加到名为b2c-extensions-app 的应用程序。 Do not modify this application, as it's used by Azure AD B2C for storing user data.
不要修改此应用程序,因为 Azure AD B2C 使用它来存储用户数据。 You can find this application under Azure AD B2C, app registrations.
您可以在 Azure AD B2C、应用注册下找到此应用程序。
You can find this application in Azure AD -> App Registration.您可以在 Azure AD -> App Registration 中找到此应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.