简体   繁体   English

Microsoft Graph SDK 未返回 Azure AD B2C 用户的自定义属性值

[英]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.

相关问题 在Azure AD B2C中使用Microsoft.Graph SDK创建本地帐户 - Create local account using Microsoft.Graph SDK in Azure AD B2C Azure AD B2C和图:无法列出具有memberOf的用户 - Azure AD B2C and Graph: cannot list users with memberOf 使用Graph API在Azure AD B2C中创建具有自定义属性的用户 - Create user with Custom Attributes in Azure AD B2C with Graph API 无法使用 asp.net 核心图 API 在 Azure AD B2C 中创建自定义属性 - Can't create custom attributes in Azure AD B2C with asp.net core Graph API 带有 B2C AD 的 Azure Graph - Azure Graph with B2C AD Microsoft graph 更改 azure ad b2c 用户密码不起作用 - Microsoft graph change azure ad b2c user password not working 使用 Microsoft Graph + Http 客户端更改 Azure AD B2C 上的用户密码 - Change user password on Azure AD B2C using Microsoft Graph + Http Client 如何以编程方式通过 Microsoft Graph 获取 Azure AD b2c 登录日志 - how to get Azure AD b2c sign-in logs through Microsoft Graph programatically 如何在不使用Microsoft页面的情况下在Azure AD B2C中使用graph api进行社交登录? - How to use graph api for social login in Azure AD B2C without using Microsoft page? Azure AD B2C.Net SDK - 通过 Email 检索用户 - Azure AD B2C .Net SDK - Retrieve User by Email
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM