Xamarin Formsアプリケーションを認証しようとしていますが、Windows名前空間クラスとメソッドの代わりにWebAuthenticationBroker.GetCurrentApplicationCallbackUriの代替を見つけることができません。XamarinはWebAuthenticationBrokerと同等です。GetCurrentApplicationCallbackUri?
Xamarin Forms UWPアプリでは、RedirectURLを取得するために使用できますが、iOSとAndroidアプリについてどうすればよいか分かりません。 :
class Authenticator : IAuthenticator
{
/// <summary>
/// Address to return to upon receiving a response from the authority.
/// </summary>
private static readonly Uri RedirectURI = WebAuthenticationBroker.GetCurrentApplicationCallbackUri();
public async Task<AuthenticationResult> AuthenticateAsync(UserLogOn user, string authority, string resource, Uri redirectURI, string clientId)
{
PlatformParameters platformParams = new PlatformParameters(PromptBehavior.Always, false);
try
{
var authContext = new AuthenticationContext(authority);
var authResult = await authContext.AcquireTokenAsync(resource, clientId, RedirectURI, platformParams);
return authResult;
}
catch (Exception e)
{
Debug.WriteLine($"AquireTokenAsync Error: {e.Message}");
return null;
}
}
}
は、それは私が私たちのAzure ADアカウントにアクセス許可の問題を持っていたことが判明し、それを解決した後に、これは私が使用して終了することをAndroidとiOSのためのソリューションである、 マーク
今のところ、いくつかの詳細が欠落しているので、良い質問をするのは難しいです。どのライブラリを認証に使用していますか? 'Xamarin.Auth'?あなたはUWPのために表示しているコードですか? – Demitrian
はい、それはUWPコードです。私はADAL:Microsoft.IdentityModel.Clients.ActiveDirectoryを使用しています。 Xamarin.Authは2年以上も触れられていないように見えるので、私はそれを使いたいとは思っていません。しかし、私は柔軟です。主なことは、すべての適切な情報を持つトークンバックが必要であり、GetCurrentApplicationCallbackUriメソッドが明らかにアプリケーションのWindow Store IDとRedirectURLを関連付けることです。だから、iOSとAndroidアプリのために、iOSとAndroidの中からGetCurrentApplicationCallbackUriメソッドを使う方法を理解する必要があると思います。 –
@MarkGarcia Xamarin Authライブラリは古いものがあるので混乱していますが、[this](https://www.nuget.org/packages/Xamarin.Auth/)のバージョンは定期的に入手できます更新。 – hvaughan3