[Xamarin.Auth][Android][Twitter] How to properly use OAuth1Authenticator

tkowalczyktkowalczyk PLMember, University ✭✭

Hi All,
I'm using my own LoginTwitterViewRenderer to give ability users to authenticate with Twitter credentials. I know that Twitter use OAuth1 for login. So here is my code for this it's almost done, but when I set some real callbackUrl for example (http://google.com) this page is opened after authorization but the method TwitterCompleted is not fired?! But when I set callbackUrl as Method is fired I can even see my Twitter login and the debug info but I also receive a "Authentication Error" popup on the screen saying "Object reference not set to an instance of an object."

    ` var auth = new OAuth1Authenticator(
                    consumerKey: "xxxxx",
                    consumerSecret: "xxxxxx",
                    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("https://google.com"),
                    getUsernameAsync: (IDictionary<string, string> account) =>
                        string screen_name = "";
                        if (account.TryGetValue("screen_name", out screen_name))
                            Console.WriteLine("SN: {0}", screen_name);
                            Account a = new Account(screen_name, account);
                            AuthenticatorCompletedEventArgs args = new AuthenticatorCompletedEventArgs(a);
                        return null;

And the event method:

    `private void TwitterCompleted(AuthenticatorCompletedEventArgs args)
                if (args.IsAuthenticated)
                    //// Use eventArgs.Account to do wonderful things
                    //// Use for store auth service name
                    Console.WriteLine("==============User authenticated======================");
                    Console.WriteLine("==============User NOT authenticated======================");

Please tell me what did I missed?

Sign In or Register to comment.