我正在开发一个需要通过 Azure AD 对用户进行身份验证的 Xamarin 应用程序,为此我使用了 Microsoft.Identity.Client 块。
该应用程序能够转到 Microsoft SSO 页面,但在点击登录按钮后,该页面返回错误:AADSTS50011:请求中指定的回复 url 与为应用程序配置的回复 url 不匹配:[ApplicationID]
应用类:
public static string ClientID = [ApplicationID];
public static string[] Scopes = { "User.Read" };
public static string Username = string.Empty;
public static UIParent UiParent { get; set; }
public App()
{
InitializeComponent();
PCA = new PublicClientApplication(ClientID);
PCA.RedirectUri = $"msal{App.ClientID}://auth";
//PCA.RedirectUri = $"AppSGA://auth";
MainPage = new Paginas.Login();
}
Run Code Online (Sandbox Code Playgroud)
在构造函数的第四行中,如果我使用 PCA.RedirectUri = "AppSGA://auth"; 而不是 PCA.RedirectUri = $"msal{App.ClientID}://auth"; 它不会返回错误,但 sso 页面将永远加载而没有任何响应。
登录页面的登录方法:
private async void …Run Code Online (Sandbox Code Playgroud)