简体   繁体   English

使用Azure AD B2C的Xamarin.Forms应用仅显示Microsoft登录

[英]Xamarin.Forms app using Azure AD B2C only showing Microsoft login

I'm developing a Xamarin app that uses Azure AD B2C and I'm having some trouble. 我正在开发使用Azure AD B2C的Xamarin应用程序,但遇到了一些麻烦。

Even though I have LinkedIn, Google, Microsoft, Facebook, and Twitter setup as Identity Providers, the only thing I am ever prompted for is my Microsoft account. 即使我将LinkedIn,Google,Microsoft,Facebook和Twitter设置为身份提供者,但我唯一得到的提示还是我的Microsoft帐户。 I don't see any of the other buttons when my app invokes the login. 当我的应用调用登录时,我看不到其他任何按钮。 Works great for Microsoft login, can't access any of the others. 非常适合Microsoft登录,不能访问其他任何一个。

Here is my call to AcquireTokenAsync: 这是我对AcquireTokenAsync的调用:

var result = await AuthenticationClient.AcquireTokenAsync(Constants.Scopes, 
    GetUserByPolicy(App.AuthenticationClient.Users, Constants.PolicySignUpSignIn), 
    Evaluator.App.UiParent);

In the Azure AD B2C settings in the portal, I have Web App / Web API set to NO, Native client set to YES. 在门户网站的Azure AD B2C设置中,我将Web App / Web API设置为NO,将本机客户端设置为YES。 The Custom Redirect URI is “masl{myappid}://auth”. 自定义重定向URI为“ masl {myappid}:// auth”。
Under Keys it says “No results”. 在“键”下显示“无结果”。 Under API access (Preview) it says there are 2 scopes (both checkboxes checked for openid and offline_access). 在“ API访问(预览)”下,它表示有2个作用域(两个复选框都选中了openid和offline_access)。 Under published scopes (Preview) it says Web app / Web API has not been included. 在已发布的范围(预览)下,它表示未包含Web应用程序/ Web API。

Under Identity providers, I have LinkedIn, Google, Microsoft, Facebook, and Twitter configured. 在身份提供者下,我配置了LinkedIn,Google,Microsoft,Facebook和Twitter。

It turns out that changing to use one of the other overloads of AcquireTokenAsync causes different behavior. 事实证明,更改为使用AcquireTokenAsync的其他重载之一会导致不同的行为。

var result = //await AuthenticationClient.AcquireTokenAsync(Constants.Scopes, GetUserByPolicy(App.AuthenticationClient.Users, Constants.PolicySignUpSignIn), Evaluator.App.UiParent);
    await App.AuthenticationClient.AcquireTokenAsync(Constants.Scopes, GetUserByPolicy(App.AuthenticationClient.Users, Constants.PolicySignUpSignIn), UIBehavior.SelectAccount, string.Empty, null, Constants.Authority, App.UiParent);

The original call caused the Azure AD service to be called, and the call shown here causes the Azure B2C service to be called instead. 原始调用导致调用Azure AD服务,此处显示的调用导致调用Azure B2C服务。 I don't see that documented anywhere, and I wish all the overloads had better documentation describing the relevance and distinctions in behavior between them. 我在任何地方都看不到文档,但我希望所有重载都有更好的文档来描述它们之间行为的相关性和区别。

Now I see all the providers I had configured showing up as options! 现在,我看到所有配置的提供程序都显示为选项! However, there's a new problem in that (despite the fact that they appear to be configured correctly) I no longer get an email address back in the result.User.DisplayableId field. 但是,存在一个新问题(尽管它们似乎配置正确),我再也没有在result.User.DisplayableId字段中获取电子邮件地址。 Despite this, my original question is answered. 尽管如此,我的原始问题得到了回答。

Configure your Policy Identity Providers (IDPs) 配置策略身份提供者(IDP)

配置策略IDPS屏幕截图

Sample Policy 样本政策

登录屏幕截图

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

相关问题 Azure AD B2C在Xamarin.Forms iOS应用中指定多个身份提供程序 - Azure AD B2C Specify multiple Identity Providers in Xamarin.Forms iOS app 如何使用Azure AD B2C身份验证开发多用户Xamarin.Forms应用 - How to develop a multi-user Xamarin.Forms app with Azure AD B2C authentication Xamarin Forms和Azure AD B2C登录问题 - Xamarin Forms and Azure AD B2C login issues Azure B2C 忘记密码未显示在 Xamarin.Forms UWP 应用程序上 - Azure B2C Forgot password is not showing on Xamarin.Forms UWP app 在AAD B2C中将刷新令牌与Azure App Service和Xamarin.Forms一起使用 - Using a refresh token in AAD B2C with Azure App Service and Xamarin.Forms 如何使用 MSAL 将现有 Azure AD B2C 集成到 Xamarin forms 应用程序中? - How to Integrate existing Azure AD B2C into a Xamarin forms app using MSAL? Azure AD B2C 上 Xamarin.Forms 抛出错误 B2C '权限' Uri 应该至少有 3 个段 - Azure AD B2C on Xamarin.Forms throwing error B2C 'authority' Uri should have at least 3 segments Xamarin.forms 的 Azure AD B2C“Safari 无法打开页面,因为地址无效”? - Azure AD B2C for Xamarin.forms "Safari cannot open the page because the address is invalid"? Xamarin.forms和Azure AD B2C-缺少PublicClientApplication.PlatformParameters? - Xamarin.forms and Azure AD B2C - missing PublicClientApplication.PlatformParameters? 401 在 Xamarin.Forms 上未经 Azure b2c 授权 - 401 Unauthorized with Azure b2c on Xamarin.Forms
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM