简体   繁体   English

Xamarin Forms:使用 MSAL 的 Azure AD B2C:通过代码设置客户端 ID

[英]Xamarin Forms: Azure AD B2C using MSAL: Set Client Id through code

I am trying to use MSAL for Azure AD B2C authentication in Xamarin forms.我正在尝试在 Xamarin 表单中使用 MSAL 进行 Azure AD B2C 身份验证。 I have followed this tutorial: Tutorial我遵循了本教程: 教程

But this asks to set the client id in Intent Filter.但这要求在 Intent Filter 中设置客户端 ID。 What if i am building a product and it needs to be distributed to more then one customer through public store?如果我正在构建一个产品并且它需要通过公共商店分发给多个客户怎么办?

Is there any way we can set the client ID programmatically?有什么办法可以以编程方式设置客户端 ID? Please help.请帮忙。 Thank you.谢谢你。

You should not set client ID programmatically.您不应以编程方式设置客户端 ID。

If you want your customer from different tenants to use your B2C project, you just need to configure your Azure AD app as multi-tenant.如果希望不同租户的客户使用你的 B2C 项目,只需将 Azure AD 应用配置为多租户即可。

Just like the document you shared mentions:就像你分享的文档提到的:

Select Accounts in any organizational directory or any identity provider.在任何组织目录或任何身份提供者中选择帐户。

And then you could Set up sign-in for multi-tenant Azure Active Directory using custom policies in Azure Active Directory B2C .然后,您可以使用 Azure Active Directory B2C 中的自定义策略为多租户 Azure Active Directory 设置登录 Then customer will be able to log into your project with their own credentials.然后客户将能够使用他们自己的凭据登录到您的项目。

In fact , you don't even need to configure sign-in for multi-tenant Azure Active Directory using custom policies.事实上,您甚至不需要使用自定义策略为多租户 Azure Active Directory 配置登录。 Customers could sign up to your B2C tenant to use your product.客户可以注册您的 B2C 租户以使用您的产品。 This is exactly how B2C works.这正是 B2C 的运作方式。

The client id used in the IntentFilter on that particular tutorial is for the DataScheme which needs to be unique, so AAD knows where to redirect after the authentication screen.该特定教程的IntentFilter使用的客户端 ID 用于需要唯一的DataScheme ,因此 AAD 知道在身份验证屏幕之后重定向到哪里。 You could use a different value if you want.如果需要,您可以使用不同的值。 It is common to use the reverse-DNS for that field (as for the app package).通常对该字段使用反向 DNS(对于应用程序包)。

In other words, clientId is not mandatory for that field.换句话说, clientId对于该字段不是必需的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM