Xamarin Android Xamarin.Auth - Twitter [英] Xamarin Android Xamarin.Auth - Twitter

查看:27
本文介绍了Xamarin Android Xamarin.Auth - Twitter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Xamarin Android 中实现 Twitter 登录时遇到问题.我已经包含了 Xamarin.Auth 组件,它适用于 Facebook.Fot twitter auth.Completed 事件未调用...我在 twitter 开发门户上创建了示例应用.

I have a problem with implementing twitter login in my Xamarin Android. I have included Xamarin.Auth component and it works fine for Facebook. Fot twitter auth.Completed event is not called... I have created sample app on twitter dev portal.

这是我的应用程序代码:

Here is my code from the app:

private void LoginTwitter()
    {
        var auth = new OAuth1Authenticator(
                  consumerKey: "3v7rOXkdexGYhQmr3HVhtGgPO",
                  consumerSecret: "mGhRjee87tAp4X0vHUmMIohWoYy0JGg9zFGyin7CigFP64y3j5",
                  requestTokenUrl: new Uri("https://api.twitter.com/oauth/request_token"),
                  authorizeUrl: new Uri("https://api.twitter.com/oauth/authorize"),
                  accessTokenUrl: new Uri("https://api.twitter.com/oauth/access_token"),
                  callbackUrl: new Uri("http://twitter.com")
              );
        auth.AllowCancel = true;
        StartActivity(auth.GetUI(this));
        auth.Completed += (s, eventArgs) =>
        {
            if (eventArgs.IsAuthenticated)
            {

                Account loggedInAccount = eventArgs.Account;
                //save the account data for a later session, according to Twitter docs, this doesn't expire
                AccountStore.Create(this).Save(loggedInAccount, "Twitter");
            }
        };
    }

希望有人帮忙.

推荐答案

好的,问题我自己解决了.创建新的 OAuth1Authenticator 时回调网址应设置为 mobile.twitter.com 而不是 twitter.com

Ok, I have solved the problem by myself. When creating new OAuth1Authenticator CallBack Url should be set to mobile.twitter.com not twitter.com

callbackUrl: new Uri("http://mobile.twitter.com")

之后您将能够获得令牌.

After that you will be able to obtain token.

希望它会在将来对某人有所帮助.:)

Hope it will help someone in the future. :)

您现在需要使用 http://mobile.twitter.com/home-

这篇关于Xamarin Android Xamarin.Auth - Twitter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆