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 http://127.0.0.1. 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);
TwitterCompleted(args);
}
return null;
});`
And the event method:
`private void TwitterCompleted(AuthenticatorCompletedEventArgs args)
{
if (args.IsAuthenticated)
{
App.SuccessfulLoginAction.Invoke();
//// Use eventArgs.Account to do wonderful things
App.SaveToken(args.Account.Properties["access_token"]);
//// Use for store auth service name
App.SaveAuthService("Twitter");
Console.WriteLine("==============User authenticated======================");
}
else
{
Console.WriteLine("==============User NOT authenticated======================");
}
}`
Please tell me what did I missed?