//Twitter with OAuth1
var auth = new OAuth1Authenticator(
consumerKey: "using twitter Consumer API keys",
consumerSecret: "using twitter Consumer API secret keys",
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://www.website.com.")
);
auth.AllowCancel = true; // auth.ShowUIErrors = false; // If authorization succeeds or is canceled, .Completed will be fired. auth.Completed += (s, eventArgs) => { // We presented the UI, so it's up to us to dismiss it. if (eventArgs.IsAuthenticated) { //Utilities.userDetailsTW = new UserDetailsTW(); //Utilities.userDetailsTW.Token = eventArgs.Account.Properties["oauth_token"]; //Utilities.userDetailsTW.TokenSecret = eventArgs.Account.Properties["oauth_token_secret"]; //Utilities.userDetailsTW.TwitterId = eventArgs.Account.Properties["user_id"]; //Utilities.userDetailsTW.Name = eventArgs.Account.Properties["screen_name"]; //AccountStore.Create().Save(eventArgs.Account, "Twitter"); } else { Console.WriteLine("failed"); } };
Answers
Any feedback on this issue - encountering identical error;
Hi, @RobertHellestrae you have to the same callback URL at both sides in the app created on a Twitter developer account and in you mobile app code.
//Twitter with OAuth1
var auth = new OAuth1Authenticator(
consumerKey: "< your app consumer key>",
consumerSecret: "",
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://mobile.twitter.com/home")
);
I hope this will fix the issue.
great - thanks much; later today, I can try to make adjustments;
Update: modified callback URL from http://mobile.twitter.com/home to https://mobile.twitter.com/home;
Making progress...
Authenticate screen of Twitter displays correctly with above callback URL adjustment - and includes details from Twitter Developer app, etc;
However, after entering username and password - following popup message displays:
"Authentication.Error
e.Message = The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."
@RobertHellestrae, this issue usually comes in iOS app. you have to add the below keys in your info.plist file of the iOS project.
And then clean and build the project.
thanks - issue resolved;
I got an error when cancelling authenticate the user. It works fine if I completed the login. Can anyone tell me why?
System.AggregateException: 'One or more errors occurred. (The remote server returned an error: (401) Authorization Required.)'