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
        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);
            }
        }