Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        //Dictionary<string, string> dic_followers;
        public Twitter()
        {
            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");
            consumer_secret = appSettings.Get("Twitter_consumer_secret");
            consumer_key = appSettings.Get("Twitter_consumer_key");

            amDB = new AwarenessMapDB();
            amDB.getTwitterAuth(ref accessToken, ref accessTokenSecret);
            if (accessToken == "" || accessTokenSecret == "")
            {

                InitializeOAuth initializeOAuthChoreo = new InitializeOAuth(session);

                // Set inputs
                initializeOAuthChoreo.setConsumerSecret(consumer_secret);
                initializeOAuthChoreo.setConsumerKey(consumer_key);

                // Execute Choreo
                InitializeOAuthResultSet initializeOAuthResults = initializeOAuthChoreo.execute();

                // Print results
                //Console.WriteLine("Twitter:");
                //Console.WriteLine(initializeOAuthResults.AuthorizationURL);
                //Console.WriteLine(initializeOAuthResults.CallbackID);
                //Console.WriteLine(initializeOAuthResults.OAuthTokenSecret);

                callBackId = initializeOAuthResults.CallbackID;
                oauthTokenSecret = initializeOAuthResults.OAuthTokenSecret;

                Process.Start(initializeOAuthResults.AuthorizationURL);
                Thread.Sleep(10000);

                FinalizeOAuth finalizeOAuthChoreo = new FinalizeOAuth(session);

                // Set inputs
                finalizeOAuthChoreo.setCallbackID(callBackId);
                finalizeOAuthChoreo.setOAuthTokenSecret(oauthTokenSecret);
                finalizeOAuthChoreo.setConsumerSecret(consumer_secret);
                finalizeOAuthChoreo.setConsumerKey(consumer_key);

                // Execute Choreo
                FinalizeOAuthResultSet finalizeOAuthResults = finalizeOAuthChoreo.execute();

                // Print results
                //Console.WriteLine("Secret="+finalizeOAuthResults.AccessTokenSecret);
                //Console.WriteLine("AccessToken="+finalizeOAuthResults.AccessToken);
                //Console.WriteLine("Error="+finalizeOAuthResults.ErrorMessage);
                //Console.WriteLine("SreenName="+finalizeOAuthResults.ScreenName);
                //Console.WriteLine("UserID="+finalizeOAuthResults.UserID);
                accessToken = finalizeOAuthResults.AccessToken;
                accessTokenSecret = finalizeOAuthResults.AccessTokenSecret;
                amDB.updateTwitterAuth(accessToken, accessTokenSecret);
            }
            //Console.ReadKey();
        }
Exemplo n.º 3
0
        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);
            }
        }
Exemplo n.º 4
0
        /// <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);
            }
        }