public string TwitterAuth() { var appCreds = new ConsumerCredentials(_credentialService.getConsumerKey(), _credentialService.getConsumerSecret()); IAuthenticationContext authenticationContext = AuthFlow.InitAuthentication(appCreds, _credentialService.getRedirectUrl()); return(authenticationContext.AuthorizationURL); }
public TwitterClient(string key, string secret, string redirectUrl) { ApiKey = key; ApiSecret = secret; RedirectUrl = redirectUrl; AppCredentials = new ConsumerCredentials(key, secret); }
public ActionResult TwitterAuth() { var appCreds = new ConsumerCredentials(CONSUMER_KEY, CONSUMER_SECRET); var redirectURL = "http://" + Request.Url.Authority + "/Home/ValidateTwitterAuth"; var url = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL); return(new RedirectResult(url)); }
public IConsumerCredentials Clone() { var clone = new ConsumerCredentials(ConsumerKey, ConsumerSecret); CopyPropertiesToClone(clone); return(clone); }
//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)); }
public IConsumerCredentials Clone() { var clone = new ConsumerCredentials(ConsumerKey, ConsumerSecret); CopyPropertiesToClone(clone); return clone; }
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 Task <ITwitterResult> UnsubscribeFromAccountActivity(IUnsubscribeFromAccountActivityParameters parameters, ITwitterRequest request) { var consumerCredentials = new ConsumerCredentials(request.Query.TwitterCredentials); request.Query.Url = _accountActivityQueryGenerator.GetUnsubscribeToAccountActivityQuery(parameters); request.Query.HttpMethod = HttpMethod.DELETE; request.Query.TwitterCredentials = new TwitterCredentials(consumerCredentials); return(_twitterAccessor.ExecuteRequest(request)); }
public Task <ITwitterResult <IWebhookEnvironmentSubscriptionsDTO> > GetAccountActivitySubscriptions(IGetAccountActivitySubscriptionsParameters parameters, ITwitterRequest request) { var consumerCredentials = new ConsumerCredentials(request.Query.TwitterCredentials); request.Query.Url = _accountActivityQueryGenerator.GetAccountActivitySubscriptionsQuery(parameters); request.Query.HttpMethod = HttpMethod.GET; request.Query.TwitterCredentials = new TwitterCredentials(consumerCredentials); return(_twitterAccessor.ExecuteRequest <IWebhookEnvironmentSubscriptionsDTO>(request)); }
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 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)); }
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 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)); }
private void button1_Click(object sender, EventArgs e) { textbox_consumertoken.Enabled = false; textbox_consumersecret.Enabled = false; var applicationCredentials = new ConsumerCredentials(textbox_consumertoken.Text, textbox_consumersecret.Text); authenticationContext = AuthFlow.InitAuthentication(applicationCredentials); System.Diagnostics.Process.Start(authenticationContext.AuthorizationURL); button_request.Enabled = false; textbox_usertoken.Enabled = true; }
//private const string TwitterConsumerKey = "unZjcnD6BB0vbU5TfTiXPGnVe"; //private const string TwitterConsumerSecret = "7VoiPTrbqaq1vnuu87U4CAbYDyfiqJwlSanN6LvzGkfQ43f1fj"; // // GET: /Twitter/ public ActionResult Index() { if (Session["TwitterLogin"] != null && Session["TwitterLogin"].ToString() == "YES") { return(RedirectToAction("Home")); } var appCreds = new ConsumerCredentials(TwitterConsumerKey, TwitterConsumerSecret); var redirectURL = "http://userprofiler.azurewebsites.net/twitter/Callback"; //var redirectURL = "http://127.0.0.1/SocialAnalyzer/twitter/Callback"; var url = Tweetinvi.CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL); return(Redirect(url)); }
// 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); }
/// <summary> /// Get the credentials from a PIN CODE/OAUTH VERIFIER provided by twitter.com to the user. /// /// This method generates the credentials from the ConsumerCredentials used to get the Authentication URL. /// </summary> /// <param name="verifierCode"> /// - PIN CODE Authentication : User enters the pin given on twitter.com /// - URL REDIRECT : Use the value of the 'oauth_verifier' url parameter. /// </param> /// <param name="authorizationKey">Authorization Key of the same credentials as the one given as a parameter to get the Authentication URL.</param> /// <param name="authorizationSecret">Authorization Secret of the same credentials as the one given as a parameter to get the Authentication URL.</param> /// <param name="consumerKey">Consumer Key of the same credentials as the one given as a parameter to get the Authentication URL.</param> /// <param name="consumerSecret">Consumer Secret of the same credentials as the one given as a parameter to get the Authentication URL.</param> public static ITwitterCredentials GetCredentialsFromVerifierCode( string verifierCode, string authorizationKey, string authorizationSecret, string consumerKey, string consumerSecret) { var appCredentials = new ConsumerCredentials(consumerKey, consumerSecret) { AuthorizationKey = authorizationKey, AuthorizationSecret = authorizationSecret }; return(_credentialsCreator.GetCredentialsFromVerifierCode(verifierCode, appCredentials)); }
public IActionResult Login() { var consumerKey = _configuration["Twitter:ConsumerApiKey"]; var consumerSecret = _configuration["Twitter:ConsumerApiSecret"]; var appCreds = new ConsumerCredentials(consumerKey, consumerSecret); // Twitter で認証後にリダイレクトされるURL var redirectURL = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/Account/ValidateAuth"; // Twitter にリクエストを送信して認証画面のURLを取得 var authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); // Twitter の認証画面へのリダイレクト return(this.Redirect(authenticationContext.AuthorizationURL)); }
public IAuthenticatedUser GetAuthenticatedUser(string oauthVerifier, string authorizationKey, string authorizationSecret) { var appCreds = new ConsumerCredentials(AppSettings.TwitterConsumerKey, AppSettings.TwitterConsumerSecret); var token = new AuthenticationToken() { AuthorizationKey = authorizationKey, AuthorizationSecret = authorizationSecret, ConsumerCredentials = appCreds }; var userCredentils = AuthFlow.CreateCredentialsFromVerifierCode(oauthVerifier, token); var user = User.GetAuthenticatedUser(userCredentils); return(user); }
public string TwitterAuth() { AuthorizeOurApp(); var appCreds = new ConsumerCredentials( Environment.GetEnvironmentVariable("CONSUMER_KEY"), Environment.GetEnvironmentVariable("CONSUMER_SECRET") ); var redirectURL = Environment.GetEnvironmentVariable("redirectURL"); IAuthenticationContext _authenticationContext = AuthFlow.InitAuthentication(appCreds, redirectURL); _cache.Set("_authContext", _authenticationContext); return(_authenticationContext.AuthorizationURL); }
public void LoadOAuthAuthenticator(OAuthSettings settings) { if (settings.AccessToken.IsNullOrWhitespace() || settings.AccessTokenSecret.IsNullOrWhitespace()) { throw new AuthenticationException("Missing access token or secret. Cannot create Authenticator"); } var consumer = new ConsumerCredentials(settings.ConsumerKey, settings.ConsumerSecret); client_.Authenticator = OAuth1Authenticator.ForProtectedResource( consumer.Key, consumer.Secret, settings.AccessToken, settings.AccessTokenSecret, OAuthSignatureMethod.RsaSha1); }
public static string GetBearerToken(ConsumerCredentials userCredentials, string webMethod, string url) { C4MAuthentication auth = new C4MAuthentication { ConsumerKey = userCredentials.ConsumerKey, Nonce = GetNonce(), Timestamp = ToEpochTime(DateTime.Now) }; auth.Signature = GetSignatureHash(userCredentials.ConsumerSecret, (userCredentials.ConsumerSecret + auth.ConsumerKey + auth.Nonce + auth.Timestamp + auth.Version + webMethod.ToUpperInvariant() + url.ToUpperInvariant())); //Newtonsoft json is not working properly yet with Blazor.. so doing manually.. return(Convert.ToBase64String(Encoding.UTF8.GetBytes(auth.ToString()))); }
/// <summary> /// Requests an authentication token and redirects the user to Twitter /// </summary> public ActionResult Oauth() { ConsumerCredentials appCreds; string redirectURL, oauthURL; try { Session[SK.Redirect] = Request.QueryString["redirect_uri"]; appCreds = new ConsumerCredentials(consumerKey, consumerSecret); redirectURL = "http://" + Request.Url.Authority + "/twitter/callback"; oauthURL = CredentialsCreator.GetAuthorizationURL(appCreds, redirectURL); return(new RedirectResult(oauthURL)); } catch (Exception) { return(new RedirectResult("/twitter/check")); } }
public IAuthenticationContext InitAuthentication(string redirectUri) { var appCreds = new ConsumerCredentials(AppSettings.TwitterConsumerKey, AppSettings.TwitterConsumerSecret); return(AuthFlow.InitAuthentication(appCreds, redirectUri)); }
public static void Main(string[] args) { Cancellation.Token.Register(() => MRE.Set()); Console.CancelKeyPress += (s, e) => { e.Cancel = true; Cancellation.Cancel(); }; AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; Log($@"KotoriNSFW v{Version}", ConsoleColor.Green); Log(@"THis is still experimental, don't look at it."); Log(@"WARNING: THIS WILL POST NSFW EVEN IF BOT_RATING IS SET TO S", ConsoleColor.DarkRed); Log(@"Press any key if you understand and are ok with this..."); Console.ReadKey(); LogHeader(@"Creating database manager..."); Database = new DatabaseManager(); LogHeader(@"Running migrations..."); Database.RunMigrations(); MigrateIni(); if (string.IsNullOrEmpty(Database.ReadConfig(@"twitter_consumer_key"))) { LogHeader(@"Set up Twitter API keys..."); Log(@"Please enter your Twitter Consumer Key:"); Database.WriteConfig(@"twitter_consumer_key", Console.ReadLine()); Log(@"And now your Twitter Consumer Secret:"); Database.WriteConfig(@"twitter_consumer_secret", Console.ReadLine()); } LogHeader(@"Creating booru clients..."); IBooru[] boorus = new IBooru[] { new Danbooru(HttpClient), new Gelbooru(HttpClient), new Safebooru(HttpClient), new Yandere(HttpClient), new Konachan(HttpClient), }; IConsumerCredentials cc = new ConsumerCredentials( Database.ReadConfig(@"twitter_consumer_key"), Database.ReadConfig(@"twitter_consumer_secret") ); LogHeader(@"Creating bots..."); lock (Bots) foreach (TwitterBotInfo botInfo in Database.GetBots()) { if (Cancellation.IsCancellationRequested) { break; } ITwitterCredentials creds; if (string.IsNullOrEmpty(botInfo.AccessToken) || string.IsNullOrEmpty(botInfo.AccessTokenSecret)) { IAuthenticationContext ac = TwitterClient.BeginCreateClient(cc); Log(); Log($@"====> Authenticate {botInfo.Name} <====", ConsoleColor.Yellow); Log(ac.AuthorizationURL); Log(@"Enter the pin code you received:"); string pin = Console.ReadLine(); creds = TwitterClient.EndCreateClient(ac, pin); } else { creds = new TwitterCredentials(cc.ConsumerKey, cc.ConsumerSecret, botInfo.AccessToken, botInfo.AccessTokenSecret); } TwitterBot bot = new TwitterBot( Database, boorus, botInfo, new TwitterClient(creds) ); bot.SaveCredentials(); Bots.Add(bot); } LogHeader(@"Checking cache for all bots..."); lock (Bots) foreach (TwitterBot bot in Bots) { if (!bot.EnsureCacheReady()) { Log($@"Refreshing cache for {bot.Name}, this may take a little bit..."); bot.RefreshCache(); } } #if DEBUG Run(); Console.ReadLine(); #else Log($@"Posting after {UntilNextRun}, then a new post will be made every {Interval}!", ConsoleColor.Magenta); StartTimer(Run); MRE.WaitOne(); #endif lock (Bots) foreach (TwitterBot bot in Bots) { bot.Dispose(); } Database.Dispose(); }