[英]Azure AD B2C on Xamarin.Forms throwing error B2C 'authority' Uri should have at least 3 segments
I am trying to integrate Azure AD B2C into a Xamarin.Forms app.我正在尝试将 Azure AD B2C 集成到 Xamarin.Forms 应用程序中。 I am following THIS GUIDE as a starter.
我按照本指南作为初学者。 I have created Azure AD B2C tenant.
我创建了 Azure AD B2C 租户。 When I open the endpoints of the tenant here is what I see
当我打开租户的端点时,我看到的是
As you can see the general pattern for URL is https://TENANT.b2clogin.com/TENANT.onmicrosoft.com/<policy-name>/
如您所见,URL 的一般模式是
https://TENANT.b2clogin.com/TENANT.onmicrosoft.com/<policy-name>/
However, inside the sample the URL is formed differently: https://TENANT.b2clogin.com/tfp/TENANT.onmicrosoft.com/<policy-name>/
但是,在样本内部,URL 的形成方式不同:
https://TENANT.b2clogin.com/tfp/TENANT.onmicrosoft.com/<policy-name>/
Notice the tfp bit.注意tfp位。
If I remove the tfp
part from the URL formation, as soon as these lines are executed如果我从 URL 格式中删除
tfp
部分,则只要执行这些行
var builder = PublicClientApplicationBuilder.Create(B2CConstants.ClientID)
.WithB2CAuthority(B2CConstants.AuthoritySignInSignUp)
.WithIosKeychainSecurityGroup(B2CConstants.IOSKeyChainGroup)
.WithRedirectUri($"msal{B2CConstants.ClientID}://auth");
I receive the following exception我收到以下异常
System.ArgumentException: B2C 'authority' Uri should have at least 3 segments in the path (i.e. https://<host>/tfp/<tenant>/<policy>/...)
Obviously, the MSAL.NET API expects the the URI should contain the tfp
bit, but the endpoints are really without that.显然,MSAL.NET API 期望 URI 应该包含
tfp
位,但端点确实没有。
I am using the the 4.17.1
version of Microsoft.Identity.Client
.我正在使用
4.17.1
版本的Microsoft.Identity.Client
。
It does seem that the latest APIs in MSAL.NET are not compatible with the latest Azure AD B2C. MSAL.NET 中的最新 API 似乎与最新的 Azure AD B2C 不兼容。 Is there any workaround?
有什么解决方法吗?
It appears I was doing it wrong.看来我做错了。 I shouldn't have used the endpoints from the B2C itself, rather I should have created specific iOS & Android app registrations.
我不应该使用 B2C 本身的端点,而是应该创建特定的 iOS 和 Android 应用程序注册。 Here's what I have done.
这就是我所做的。
After these steps all worked OK.完成这些步骤后,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.