问题描述
荫使用Xamarin开发一个跨平台的Android应用程序。目前,我坚持与 WebAuthenticationBroker.AuthenticateAsync
方法和找不到任何等同于它。
Iam developing a cross platform android app using Xamarin. Currently I am stuck with the WebAuthenticationBroker.AuthenticateAsync
method and cannot find anything equivalent to it.
下面是我想在Android完成的:
Here is something I want to do in android:
var broker = await WebAuthenticationBroker.AuthenticateAsync(WebAuthenticationOptions.None, startUri, endUri);
var datax = broker.ResponseData;
if (broker.ResponseStatus != WebAuthenticationStatus.Success)
await new Windows.UI.Popups.MessageDialog("Invalid username or user doesn't exists").ShowAsync();
根据该文件不存在 WebAuthenticationBroker
在xamarin截至目前。是否有任何变通实现一样吗?
任何想法如何可以在Android的xamarin来实现。
According to the documentation there is no WebAuthenticationBroker
in xamarin as of now. Is there any work around for achieving the same?Any ideas how this can be achieved with android in xamarin.
推荐答案
你看?好像这就是你想要的。这里是一个小code段这会给你一个你可以用它做什么提示:
Did you look at the Xamarin.Auth? It seems like that's what you want. Here is a little code snippet which would give you a hint about what you can do with it:
using Xamarin.Auth;
...
var auth = new OAuth2Authenticator (
clientId: "App ID from https://developers.facebook.com/apps",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
回调事件:
auth.Completed += (sender, eventArgs) => {
// We presented the UI, so it's up to us to dimiss it on iOS.
DismissViewController (true, null);
if (eventArgs.IsAuthenticated) {
// Use eventArgs.Account to do wonderful things
} else {
// The user cancelled
}
};
这篇关于WebAuthenticationBroker.AuthenticateAsync在android系统Xamarin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!