public IAuthenticationContext SetCredentials() { TwitterCredentials = new TwitterCredentials(TwitterConfig.ConsumerKey, TwitterConfig.ConsumerSecret); AuthenticationContext = AuthFlow.InitAuthentication(TwitterCredentials); return(AuthenticationContext); }
public static string GetAuthUrl() { try { string ConsumerKey = ConfigInfo.ConsumerKey; string ConsumerSecret = ConfigInfo.ConsumerSecret; string AccessToken = ConfigInfo.AccessToken; string AccessSecret = ConfigInfo.AccessSecret; // Credentials for Twitter Authorization gotten by making application in apps.twitter.com ITwitterCredentials AppCredentials = new TwitterCredentials(ConsumerKey, ConsumerSecret, AccessToken, AccessSecret); // Stores twitter oauth Url and recently created tokens var authenticationContext = AuthFlow.InitAuthentication(AppCredentials); // Generates string from authenticationContext AuthUrl = authenticationContext.AuthorizationURL; AuthenticationContext = authenticationContext; } catch (ArgumentException ex) { ExceptionTemplates.ArgumentException(ex); } catch (TwitterException ex) { ExceptionTemplates.TwitterException(ex); } catch (Exception ex) { ExceptionTemplates.GenericException(ex); } return(AuthUrl); }
public void AuthenticateAppViaBrowser() { var appCredentials = new TwitterCredentials(ConsumerKey, ConsumerSecret); authenticationContext = AuthFlow.InitAuthentication(appCredentials); Browser.Open(authenticationContext.AuthorizationURL); }
public static ITwitterCredentials AuthorizeAndGetCredentials(SecureString consumerKey, SecureString consumerSecret) { string consumerKeyStr = consumerKey.AsString(); string consumerSecretStr = consumerSecret.AsString(); if (consumerKeyStr.Length != 25) { // Consumer key length check Console.WriteLine("Consumer key is not 25 characters long."); return(null); } if (consumerSecretStr.Length != 50) { // Consumer secret key length check Console.WriteLine("Consumer secret is not 50 characters long."); return(null); } Console.WriteLine("Initiating PIN authentiation with given application consumer key/secret..."); var auth = AuthFlow.InitAuthentication(new ConsumerCredentials(consumerKeyStr, consumerSecretStr)); string pinNumber; if (OpenUrl(auth.AuthorizationURL)) { Console.WriteLine("Your web browser will be opened and navigate to Twitter app authentication page."); Console.WriteLine($" If not opened, manually open an web browser and navigate to: {auth.AuthorizationURL}\n"); } else { Console.WriteLine($"Opening URL failed! You can manually open an web browser and navigate to: {auth.AuthorizationURL}\n"); } Console.WriteLine("After logged in, the page will provide 7-character PIN numbers."); do { Console.Write("Please enter the correct PIN numbers here: "); pinNumber = Console.ReadLine(); } while(!(pinNumber.Length == 7 && int.TryParse(pinNumber, out _))); Console.WriteLine("\nGetting credential...\n"); ITwitterCredentials credential = AuthFlow.CreateCredentialsFromVerifierCode(pinNumber, auth); if (credential != null && !string.IsNullOrEmpty(credential.AccessToken) && !string.IsNullOrEmpty(credential.AccessTokenSecret)) { Console.WriteLine("Got credential successfully"); return(credential); } else { Console.WriteLine("Null credential. Something's wrong while getting credential."); return(null); } }
public string TwitterAuth() { var appCreds = new ConsumerCredentials(_credentialService.getConsumerKey(), _credentialService.getConsumerSecret()); IAuthenticationContext authenticationContext = AuthFlow.InitAuthentication(appCreds, _credentialService.getRedirectUrl()); return(authenticationContext.AuthorizationURL); }
public void Autorize() { SettingsWorker settingsWorker = new SettingsWorker("Settings.ini"); settingsWorker.LoadSettings(); Auth.SetUserCredentials(settingsWorker.settings.consumerKey, settingsWorker.settings.consumerSecret, settingsWorker.settings.userAccessToken, settingsWorker.settings.userAccessSecret); if (User.GetAuthenticatedUser() == null) //invalid Credentials { try { var appCredentials = new Tweetinvi.Models.TwitterCredentials( settingsWorker.settings.consumerKey, settingsWorker.settings.consumerSecret); var authenticationContext = AuthFlow.InitAuthentication(appCredentials); Process.Start(authenticationContext.AuthorizationURL); var pinCode = Console.ReadLine(); var newCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext); Auth.SetCredentials(newCredentials); settingsWorker.settings.userAccessToken = newCredentials.AccessToken; settingsWorker.settings.userAccessSecret = newCredentials.AccessTokenSecret; settingsWorker.SaveSettings(); } catch { throw new Exception("Autorization Failed!"); } } }
/// <summary>Prompt the user to Authorize the MemeCannon to make tweets</summary> private static void UpdateUserSettings() { ITwitterCredentials appCreds = Auth.SetApplicationOnlyCredentials(twitterConsumerKey, twitterConsumerSecret); // This method execute the required webrequest to set the bearer Token Auth.InitializeApplicationOnlyCredentials(appCreds); // Create a new set of credentials for the application. TwitterCredentials appCredentials = new TwitterCredentials(twitterConsumerKey, twitterConsumerSecret); IAuthenticationContext authenticationContext = AuthFlow.InitAuthentication(appCredentials); ProcessStartInfo psi = new ProcessStartInfo(authenticationContext.AuthorizationURL) { UseShellExecute = true, Verb = "open" }; // Causes a WebBrowser to open and the user needs to OK app access Process.Start(psi); // Ask the user to enter the pin code given by Twitter Console.WriteLine("Enter PIN Code given by Twitter to continue:"); string pinCode = Console.ReadLine(); // With this pin code it is now possible to get the credentials back from Twitter ITwitterCredentials userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(pinCode, authenticationContext); // Save off the accessToken and accessTokenSecret Program.CannonCfg.AccessToken = userCredentials.AccessToken; Program.CannonCfg.AccessTokenSecret = userCredentials.AccessTokenSecret; FileHelper.WriteJSONToFile("./CannonConfig.json", Program.CannonCfg.ToJson()); }
public string startAuthFlow() { var appCredentials = new TwitterCredentials(ct, cs); authenticationContext = AuthFlow.InitAuthentication(appCredentials); return(authenticationContext.AuthorizationURL); }
public void LoadTwitterCredentials() { TwitterCredentials = new TwitterCredentials(TwitterConfig.ConsumerKey, TwitterConfig.ConsumerSecret, TwitterConfig.AccessToken, TwitterConfig.AccessTokenSecret); AuthenticationContext = AuthFlow.InitAuthentication(TwitterCredentials); Auth.SetCredentials(TwitterCredentials); }
public async Task <bool> AuthenticateUser() { const string consumerKey = Credentials.TwitterConsumerKey; const string consumerSecret = Credentials.TwitterConsumerSecret; var userCredentials = GetCredentials(); if (userCredentials != null) { Auth.SetUserCredentials(consumerKey, consumerSecret, userCredentials.AccessToken, userCredentials.AccessTokenSecret); return(true); } var appCredentials = new TwitterCredentials(consumerKey, consumerSecret); _authenticationContext = AuthFlow.InitAuthentication(appCredentials); if (_authenticationContext == null) { return(false); } Process.Start(_authenticationContext.AuthorizationURL); Pin = string.Empty; var dialog = new LoginDialog { DataContext = this }; await DialogHost.Show(dialog); if (string.IsNullOrWhiteSpace(Pin)) { return(false); } CreateAndSetCredentials(Pin); return(true); }
public static Android.Net.Uri LogIn() { var appCredentials = new TwitterCredentials(CONSUMER_KEY, CONSUMER_SECRET); authenticationContext = AuthFlow.InitAuthentication(appCredentials); return(Android.Net.Uri.Parse(authenticationContext.AuthorizationURL)); }
public ITwitterCredentials GetTwitterCredentials() { // Create a new set of credentials for the application. var appCredentials = new TwitterCredentials(_twitterDevApiSettings.ConsumerKey, _twitterDevApiSettings.ConsumerSecret); // Init the authentication process and store the related `AuthenticationContext`. var authenticationContext = AuthFlow.InitAuthentication(appCredentials); // Go to the URL so that Twitter authenticates the user and gives him a PIN code. var window = new TwitterOauth(authenticationContext.AuthorizationURL); window.ShowDialog(); if (string.IsNullOrWhiteSpace(window.Code)) { throw new Exception("User didn't succeed login"); } // With this pin code it is now possible to get the credentials back from Twitter var userCredentials = AuthFlow.CreateCredentialsFromVerifierCode(window.Code, authenticationContext); return(userCredentials); // Use the user credentials in your application //Auth.SetCredentials(userCredentials); }
public string Authorization() { string ConsumerKey = null; string ConsumerSecret = null; string AccessToken = null; string AccessSecret = null; try { string XML = Path.GetFullPath("Config.xml"); XmlDocument doc = new XmlDocument(); doc.Load(XML); ConsumerKey = doc.ChildNodes.Item(1).ChildNodes.Item(9).InnerText.ToString(); ConsumerSecret = doc.ChildNodes.Item(1).ChildNodes.Item(11).InnerText.ToString(); AccessToken = doc.ChildNodes.Item(1).ChildNodes.Item(13).InnerText.ToString(); AccessSecret = doc.ChildNodes.Item(1).ChildNodes.Item(15).InnerText.ToString(); } catch (FileNotFoundException) { if (GenXml == false) { GenerateXML(); } } ITwitterCredentials AppCredentials = new TwitterCredentials(ConsumerKey, ConsumerSecret, AccessToken, AccessSecret); var authenticationContext = AuthFlow.InitAuthentication(AppCredentials); string AuthUrl = authenticationContext.AuthorizationURL; AuthenticationContext = authenticationContext; return(AuthUrl); }
private void setKey() { var appCredentials = new TwitterCredentials("R4OCY4qm2RJPisvX9rlXhF7mc", textKey.Text); authenticationContext = AuthFlow.InitAuthentication(appCredentials); Process.Start(authenticationContext.AuthorizationURL); textPin.Enabled = true; }
public TwitterAuthService(BapesTwitterBotContext context, TwitterAppSettings appSettings) { _context = context; var appCredentials = new TwitterCredentials(appSettings.Key, appSettings.Secret); _authenticationContext = AuthFlow.InitAuthentication(appCredentials); }
/// <summary> /// Action for redirecting user to twiiter auth page. /// </summary> public ActionResult TwitterAuth() { var appCreds = AuthenticationHelper.GetCreds(); var redirectURL = "http://" + Request.Url.Authority + "/TwitterAuth/ValidateTwitterAuth"; var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); return(new RedirectResult(authenticationContext.AuthorizationURL)); }
public ActionResult TwitterAuth() { var appCreds = new ConsumerCredentials(MyCredentials.CONSUMER_KEY, MyCredentials.CONSUMER_SECRET); var redirectURL = "http://" + Request.Url.Authority + "/Home/ValidateTwitterAuth"; var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); return(new RedirectResult(authenticationContext.AuthorizationURL)); }
//public IActionResult Logout() => Auth.SetCredentials(null); public ActionResult TwitterAuth() { var appCreds = new ConsumerCredentials(_key, _secret); var redirectURL = "http://" + Request.Host.Value + "/Home/ValidateTwitterAuth"; var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); return(new RedirectResult(authenticationContext.AuthorizationURL)); }
private void button1_Click(object sender, EventArgs e) { appCredentials = new TwitterCredentials("LunW98nTNR2EnAaJLuVXvZZAY", "LQXZ4JgwJn07097PXv6MHEmreVXz943yZbBXYJTM0IVPz5ZsOA"); // Инициализируем процесс аутентификации и сохраняем соответствующий «AuthenticationContext». authenticationContext = AuthFlow.InitAuthentication(appCredentials); Process.Start(authenticationContext.AuthorizationURL); }
protected void loginButton_Click(object sender, EventArgs e) { var appCreds = new ConsumerCredentials(consumerKey, consumerSecret); var redirect = $"http://{Request.Url.Authority}"; var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirect); HttpContext.Current.Response.Redirect(authenticationContext.AuthorizationURL); }
public IActionResult AuthenticateTwitter() { var coreTwitterCredentials = new ConsumerCredentials( config.TwitterConfiguration.Consumer_Key , config.TwitterConfiguration.Consumer_Secret); var callbackURL = "http://" + Request.Host.Value + "/Home/ValidateOAuth"; var authenticationContext = AuthFlow.InitAuthentication(coreTwitterCredentials, callbackURL); return(new RedirectResult(authenticationContext.AuthorizationURL)); }
public ActionResult TwitterLogin() { var appCreds = new ConsumerCredentials(TwitterConsumerKey, TwitterConsumerSecret); // Specify the url you want the user to be redirected to var redirectURL = "http://127.0.0.1:64663/home/twittercallback"; _authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); return(new RedirectResult(_authenticationContext.AuthorizationURL)); }
public string UserAuthentication() { string consumerKey = "GzWUY0oTfH4AMZdnMqrm0wcde"; string consumerSecret = "QfuQ7YgmLTmvQguuw3siKrwzPCiQ9EW7NleCvhxdRrjSKhfZww"; // Create a new set of credentials for the application. var appCredentials = new TwitterCredentials(consumerKey, consumerSecret); // Init the authentication process and store the related `AuthenticationContext`. authenticationContext = AuthFlow.InitAuthentication(appCredentials); return(authenticationContext.AuthorizationURL); }
public ActionResult TwitterAuth() { //var appCredentials = new TwitterCredentials("7qDmmaoHHfR4r5ktwLdeYBCOZ", "8c1Dl5shUvLRO8P3KuQPo2EzbMIWns5ZgbqjM6TgmxiFYA2gLK"); //var authenticationContext1 = AuthFlow.InitAuthentication(appCredentials); var appCreds = new ConsumerCredentials(MyCredentials.CONSUMER_KEY, MyCredentials.CONSUMER_SECRET); var redirectURL = "http://" + Request.Url.Authority + "/Home/ValidateTwitterAuth"; //var redirectURL = "http://127.0.0.1:5000/"; var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); return(new RedirectResult(authenticationContext.AuthorizationURL)); }
/// <summary> /// Le indica a twitter que va a hacer una consulta de crendenciales. Esta consulta va a generar un PIN en caso de que sea correcto /// y el usuario tiene que digitar el pin. /// </summary> public void RequestForCredentials() { var appCredentials = new TwitterCredentials("CONSUMER-KEY", "CONSUMER-SECRET"); //GET THE CONSUMER INFORMATION ON THE TWITTER APP MANAGEMENT authenticationContext = AuthFlow.InitAuthentication(appCredentials); //This opens a web-browser and asks to the twitter client //to accept the terms, and twitter gives a code and the user // have to introduce it on the app (use the AuthByPin(String pin) method ) //Thats the PIN for auth the user and then get the data Process.Start(authenticationContext.AuthorizationURL); }
private void buttonAuthorize_Click(object sender, EventArgs e) { // Create a new set of credentials for the application. string CKey = Properties.Settings.Default.ConsumerKey; string CSecret = Properties.Settings.Default.ConsumerSecret; TwitterCredentials appCredentials = new TwitterCredentials(CKey, CSecret); // Init the authentication process and store the related `AuthenticationContext`. Program.AuthenticationContext = AuthFlow.InitAuthentication(appCredentials); // Go to the URL so that Twitter authenticates the user and gives him a PIN code. Process.Start(Program.AuthenticationContext.AuthorizationURL); }
public IAuthenticationContext Authenticate() { //todo: test settings var appCredentials = new TwitterCredentials(settings.Value.ConsumerKey, settings.Value.ConsumerSecret); Auth.SetUserCredentials( settings.Value.ConsumerKey, settings.Value.ConsumerSecret, settings.Value.AccessToken, settings.Value.TokenSecret); return(AuthFlow.InitAuthentication(appCredentials)); }
// Simple sign in button. Redirects user to page that checks authentication. protected void btnSignIn_Click(object sender, System.Web.UI.ImageClickEventArgs e) { IAuthenticationContext authenticationContext; // App credentials; Key + Secret. These should be queried from a database, but I couldn't access my database so they're visible here. It's bad I know. var appCreds = new ConsumerCredentials("eF3RYgI97aNmDambiGsYT3W0q", "uTjmvgNematqGeqwU7O5yZHlTpiRwwtqrsevLNnA1Pi3TsRe4m"); // Set URL to redirect to after authentication var redirectURL = "http://" + Request.Url.Authority + "/TwitterAuth.aspx"; // Authentication context, used when signing in with Twitter. This will also be stored to session variable for later use authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); Session["authCtx"] = authenticationContext; // Redirect to Twitter authentication Response.Redirect(authenticationContext.AuthorizationURL); }
public string RequestAuth() { // Create a new set of credentials for the application. var appCredentials = new TwitterCredentials(conKey, conSecret); // Init the authentication process and store the related `AuthenticationContext`. authenticationContext = AuthFlow.InitAuthentication(appCredentials); // Go to the URL so that Twitter authenticates the user and gives him a PIN code. if (authenticationContext is null) { return(""); } return(authenticationContext.AuthorizationURL); }
private void TwitterAuthenticatorMethod() { try { authenticationContext = AuthFlow.InitAuthentication(_appCredentials); TwitterWebView.NavigationStarting += TwitterWebViewNavigationStarting; TwitterWebView.DOMContentLoaded += TwitterWebViewDomContentLoaded; TwitterWebView.Navigate(new Uri(authenticationContext.AuthorizationURL)); } catch (Exception e) { Debug.WriteLine(e); } }