Xamarin.ios Xamarin.Auth与Twitter

Xamarin.ios Xamarin.Auth与Twitter,xamarin.ios,xamarin.android,Xamarin.ios,Xamarin.android,我正在尝试使用Facebook和Twitter实现登录。我在Facebook上使用过,但不知道如何在Twitter上使用。有什么例子吗?我的Facebook实现如下: var auth = new OAuth2Authenticator( clientId: "*****************", scope: "email", authorizeUrl: new System.Uri("https://m.facebook.com/dialog/oauth/"),

我正在尝试使用Facebook和Twitter实现登录。我在Facebook上使用过,但不知道如何在Twitter上使用。有什么例子吗?我的Facebook实现如下:

var auth = new OAuth2Authenticator(
    clientId: "*****************",
    scope: "email",
    authorizeUrl: new System.Uri("https://m.facebook.com/dialog/oauth/"),
    redirectUrl: new System.Uri("http://www.facebook.com/connect/login_success.html"));

StartActivity(auth.GetUI(this));

auth.Completed += (senderFb, eventArgs) =>
{
    if (eventArgs.IsAuthenticated)
    {
        AccountStore.Create(this).Save(eventArgs.Account, "Facebook");

        // Now that we're logged in, make a OAuth2 request to get the user's info.
        var request = new OAuth2Request("GET", new System.Uri("https://graph.facebook.com/me"), null, eventArgs.Account);

        request.GetResponseAsync().ContinueWith(t =>
        {
            if (!t.IsFaulted && !t.IsCanceled)
            {
                var obj = JsonValue.Parse(t.Result.GetResponseText());
                if (obj != null)
                {
                    var user = new UserProfile
                        {
                            FirstName = obj["first_name"],
                            LastName = obj["last_name"],
                            FacebookProfileLink = obj["link"],
                            FacebookToken = eventArgs.Account.Properties["access_token"],
                            Gender = obj["gender"] == "female" ? "Female" : "Male",
                            EmailAddress = obj["email"],
                            DisplayName = obj["name"],
                            Name = obj["name"],
                            LoginName = obj["email"]
                        };
                    SignUpUser(user);
                }
            }
        }, uiScheduler);
    }
};

您可以像这样使用oauth1

 this.Authenticator = new OAuth1Authenticator (ConsumerKey, ConsumerSecret, RequestTokenUrl, AuthorizeUrl, AccessTokenUrl, DummyCallBackUrl, (IDictionary<string, string> accountProperties) => {
   string screen_name = "";
   if (accountProperties.TryGetValue("screen_name", out screen_name)) {
      Account a = new Account(screen_name, accountProperties);
      AuthenticatorCompletedEventArgs e = new AuthenticatorCompletedEventArgs(a);
      CompleteAuthentication(e);
   }
   return null;
});
this.Authenticator=新的OAuth1Authenticator(ConsumerKey、ConsumerCret、RequestTokenUrl、AuthorizeUrl、AccessTokenUrl、DummyCallBackUrl,(IDictionary accountProperties)=>{
字符串屏幕_name=“”;
if(accountProperties.TryGetValue(“屏幕名称”,屏幕名称)){
账户a=新账户(屏幕名称、账户属性);
AuthenticatorCompletedEventArgs e=新的AuthenticatorCompletedEventArgs(a);
完全认证(e);
}
返回null;
});
twitter api不完全支持OAuth2