public GoogleOAuth(string scope) { session = new TembooSession("keepitpumping", "KeepItPumping-Awareness-Map", "692238482e2b4bc7b62d09234193c202"); InitializeOAuth initializeOAuthChoreo = new InitializeOAuth(session); // Set inputs initializeOAuthChoreo.setClientID(client_id); initializeOAuthChoreo.setScope(scope); // Execute Choreo InitializeOAuthResultSet initializeOAuthResults = initializeOAuthChoreo.execute(); Process.Start(initializeOAuthResults.AuthorizationURL); Thread.Sleep(20000); FinalizeOAuth finalizeOAuthChoreo = new FinalizeOAuth(session); // Set inputs finalizeOAuthChoreo.setCallbackID(initializeOAuthResults.CallbackID); finalizeOAuthChoreo.setClientSecret(client_secret); finalizeOAuthChoreo.setClientID(client_id); // Execute Choreo FinalizeOAuthResultSet finalizeOAuthResults = finalizeOAuthChoreo.execute(); accessToken = finalizeOAuthResults.AccessToken; refreshToken = finalizeOAuthResults.RefreshToken; amDB = new AwarenessMapDB(); }
public YouTube(string scope) { var applicationKeys = ConfigurationManager.AppSettings; client_id = applicationKeys.Get("Youtube_client_id"); client_secret = applicationKeys.Get("Youtube_client_secret"); // Instantiate the Choreo, using a previously instantiated TembooSession object, eg: session = new TembooSession("keepitpumping", "KeepItPumping-Awareness-Map", "692238482e2b4bc7b62d09234193c202"); amDB = new AwarenessMapDB(); if (scope.Contains("youtube.readonly")) { amDB.getYoutubeAuth("YouTube.readonly", ref accessToken, ref refreshToken); dbScope = "YouTube.readonly"; } else if (scope.Contains("yt-analytics.readonly")) { amDB.getYoutubeAuth("YouTube.analytics", ref accessToken, ref refreshToken); dbScope = "YouTube.analytics"; } if (accessToken == "" || refreshToken == "") { InitializeOAuth initializeOAuthChoreo = new InitializeOAuth(session); // Set inputs initializeOAuthChoreo.setClientID(client_id); initializeOAuthChoreo.setScope(scope); // Execute Choreo InitializeOAuthResultSet initializeOAuthResults = initializeOAuthChoreo.execute(); Process.Start(initializeOAuthResults.AuthorizationURL); Thread.Sleep(20000); FinalizeOAuth finalizeOAuthChoreo = new FinalizeOAuth(session); // Set inputs finalizeOAuthChoreo.setCallbackID(initializeOAuthResults.CallbackID); finalizeOAuthChoreo.setClientSecret(client_secret); finalizeOAuthChoreo.setClientID(client_id); // Execute Choreo FinalizeOAuthResultSet finalizeOAuthResults = finalizeOAuthChoreo.execute(); accessToken = finalizeOAuthResults.AccessToken; refreshToken = finalizeOAuthResults.RefreshToken; amDB.updateYoutubeAuth(dbScope, accessToken, refreshToken); } }
/// <summary> /// Main Facebook class /// Looks up authentication data in db. If not found, call Temboo services to get an accessToken. /// Save it to the db. /// </summary> public Facebook() { // Instantiate the Choreo, using a previously instantiated TembooSession object, eg: var appSettings = ConfigurationManager.AppSettings; //session = new TembooSession(appSettings.Get("Temboo_account"), // appSettings.Get("Temboo_application"), // appSettings.Get("Temboo_application_key")); session = new TembooSession("keepitpumping", "KeepItPumping-Awareness-Map", "692238482e2b4bc7b62d09234193c202"); app_id = appSettings.Get("Facebook_app_id"); app_secret = appSettings.Get("Facebook_app_secret"); amDB = new AwarenessMapDB(); amDB.getFacebookAuth(ref accessToken); if (accessToken == "") { InitializeOAuth initializeOAuthChoreo = new InitializeOAuth(session); // Set inputs initializeOAuthChoreo.setAppID(app_id); initializeOAuthChoreo.setScope("public_profile, email, user_about_me, user_friends, user_likes, user_status," + "publish_pages, publish_actions, read_insights,user_managed_groups, user_status, user_videos," + "user_website, manage_pages, read_insights"); // Execute Choreo InitializeOAuthResultSet initializeOAuthResults = initializeOAuthChoreo.execute(); callBackId = initializeOAuthResults.CallbackID; Process.Start(initializeOAuthResults.AuthorizationURL); Thread.Sleep(10000); FinalizeOAuth finalizeOAuthChoreo = new FinalizeOAuth(session); // Set inputs finalizeOAuthChoreo.setCallbackID(callBackId); finalizeOAuthChoreo.setAppSecret(app_secret); finalizeOAuthChoreo.setAppID(app_id); // Execute Choreo FinalizeOAuthResultSet finalizeOAuthResults = finalizeOAuthChoreo.execute(); accessToken = finalizeOAuthResults.AccessToken; amDB.updateFacebookAuth(accessToken); } }