コード例 #1
0
        private WorksheetEntry createSpreadSheet(string sheetName)
        {
            DocumentsService docService = new DocumentsService(this.googleAppName);

            docService.RequestFactory = GoogleOauthAccess.getRequestFactory(this.googleAppName, this.parameters);

            DocumentEntry entry = new DocumentEntry();

            entry.Title.Text = sheetName;
            entry.Categories.Add(DocumentEntry.SPREADSHEET_CATEGORY);

            DocumentEntry newEntry = docService.Insert(DocumentsListQuery.documentsBaseUri, entry);

            return(this.searchForSpreadsheet(entry.Title.Text));
        }
コード例 #2
0
        private void GoogleAuthorizeButton_Click(object sender, RoutedEventArgs e)
        {
            this.loseFocus();
            if (this.OAuthAccessCode == "")
            {
                this.DoneButton.Content = "Cancel";
                this.showBrowser();

                string urlForOauth = GoogleOauthAccess.getAuthorizationURL(this.clientId, this.clientSecret);
                this.Browser.Navigate(urlForOauth);
            }
            else
            {
                this.triggerOauthUpdate("");
            }
        }
コード例 #3
0
        public string getSpreadsheetURL(string sheetName)
        {
            DocumentsService docService = new DocumentsService(this.googleAppName);

            docService.RequestFactory = GoogleOauthAccess.getRequestFactory(this.googleAppName, this.parameters);

            Google.GData.Spreadsheets.SpreadsheetQuery query = new Google.GData.Spreadsheets.SpreadsheetQuery();

            DocumentsListQuery docQuery = new DocumentsListQuery();

            docQuery.Title = sheetName;

            DocumentsFeed feed  = docService.Query(docQuery);
            DocumentEntry entry = (DocumentEntry)feed.Entries[0];

            return("https://docs.google.com/spreadsheet/ccc?key=" + entry.ResourceId.Replace("spreadsheet:", ""));
        }
コード例 #4
0
        public GoogleSpreadsheetAccess(string appName, string clientId, string clientSecret, string OAuthAccessCode, string accessToken, string refreshToken)
        {
            this.googleAppName      = appName;
            this.googleClientId     = clientId;
            this.googleClientSecret = clientSecret;
            this.OAuthAccessCode    = OAuthAccessCode;
            this.OAuthAccessToken   = accessToken;
            this.OAuthRefreshToken  = refreshToken;

            this.parameters = GoogleOauthAccess.getOAuth2Parameters(
                this.googleClientId,
                this.googleClientSecret,
                accessToken: this.OAuthAccessCode
                );

            this.service = new SpreadsheetsService(appName);

            this.DownloadDataWorker.DoWork             += DownloadDataWorker_DoWork;
            this.DownloadDataWorker.RunWorkerCompleted += DownloadDataWorker_RunWorkerCompleted;
        }
コード例 #5
0
        public void connect(out string OAuthAccessToken, out string OAuthRefreshToken)
        {
            if (this.OAuthAccessCode != "" && this.OAuthRefreshToken == "")
            {
                GoogleOauthAccess.getAccessTokens(
                    this.googleClientId, this.googleClientSecret, this.OAuthAccessCode,
                    out this.OAuthAccessToken, out this.OAuthRefreshToken
                    );
            }
            else
            {
                this.OAuthAccessToken = GoogleOauthAccess.getRefreshedAccessToken(
                    this.googleClientId, this.googleClientSecret, this.OAuthRefreshToken
                    );
            }
            OAuthAccessToken  = this.OAuthAccessToken;
            OAuthRefreshToken = this.OAuthRefreshToken;

            this.parameters.RefreshToken = this.OAuthRefreshToken;
            this.parameters.AccessToken  = this.OAuthAccessToken;
            this.service.RequestFactory  = GoogleOauthAccess.getRequestFactory(this.googleAppName, this.parameters);
        }