public void Connect() { if (_parameters.AccessCode == null) { throw new InvalidOperationException("No access code set."); } //////////////////////////////////////////////////////////////////////////// // STEP 4: Get the Access Token //////////////////////////////////////////////////////////////////////////// // Once the user authorizes with Google, the request token can be exchanged // for a long-lived access token. If you are building a browser-based // application, you should parse the incoming request token from the url and // set it in OAuthParameters before calling GetAccessToken(). OAuthUtil.GetAccessToken(_parameters); string accessToken = _parameters.AccessToken; Console.WriteLine("OAuth Access Token: " + accessToken); //////////////////////////////////////////////////////////////////////////// // STEP 5: Make an OAuth authorized request to Google //////////////////////////////////////////////////////////////////////////// // Initialize the variables needed to make the request GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", _parameters); _service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); _service.RequestFactory = requestFactory; // Make the request to Google // See other portions of this guide for code to put here... }
private void NGAMail() { //One time Initialization across the entire session required //if (authorizationUrl == null || authorizationUrl == string.Empty) //{ string CLIENT_ID = "284081438460-sdg3dn9tt80huceeb9v4n833n97lmtlu.apps.googleusercontent.com"; string CLIENT_SECRET = "HNb2txJ2QpK0amd4IR7HAxZK"; string SCOPE = "https://spreadsheets.google.com/feeds"; string REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"; OAuth2Parameters parameters = new OAuth2Parameters(); parameters.ClientId = CLIENT_ID; parameters.ClientSecret = CLIENT_SECRET; parameters.RedirectUri = REDIRECT_URI; parameters.Scope = SCOPE; authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters); if (InputBox("AccessCode", "Input AccessCode from Browser", ref authorizationUrl) == DialogResult.OK) { parameters.AccessCode = authorizationUrl; } else { MessageBox.Show("Invallid Access Code!"); btnConnectJenkins.Enabled = true; return; } OAuthUtil.GetAccessToken(parameters); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "AlmJenkinsIntegration", parameters); spreadsheetsService.RequestFactory = requestFactory; //} }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { OAuth2Parameters parameters_lst = oauthcredentials(); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "Fusion-SpreadSheet", parameters_lst); SpreadsheetsService service = new SpreadsheetsService("Fusion-SpreadSheet"); service.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); // Iterate through all of the spreadsheets returned ddlexcellst.Items.Add("------------------- Select------------------"); foreach (SpreadsheetEntry entry in feed.Entries) { // Print the title of this spreadsheet to the screen //Response.Write(entry.Title.Text); ddlexcellst.Items.Add(entry.Title.Text); } } } catch (Exception) { Response.Redirect("Default.aspx"); } }
private void GetAccessCode(object sender, NavigationEventArgs e) { mshtml.IHTMLDocument2 doc = LoginBrowser.Document as mshtml.IHTMLDocument2; string accessCode = doc.title; if (accessCode.Substring(0, 7) == "Success") { accessCode = accessCode.Remove(0, 13); parameters.AccessCode = accessCode;// Key.Text; OAuthUtil.GetAccessToken(parameters); string accessToken = parameters.AccessToken; GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "BoardGameStats", parameters); service.RequestFactory = requestFactory; if (service != null) { DialogResult = true; } else { DialogResult = false; } } }
void Auth() { GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); service = new SpreadsheetsService("nestcoworkingspace"); service.RequestFactory = requestFactory; }
/// <summary> /// Fetches list of Google contacts. /// </summary> /// <returns></returns> public static Feed <Contact> GetGContactsList() { //Waiting for the service authentication to complete. _autoEvent.WaitOne(); Feed <Contact> feed = null; try { //In case an error was encountered go back. if (_parameters == null || _exception != null) { return(feed); } //Creating the request factory for the Drive service. GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, APPLICATION_NAME, _parameters); //Creating Request Settings instance RequestSettings settings = new RequestSettings(APPLICATION_NAME, _parameters); //Creating a request for fetching list of Google Contacts. ContactsRequest cr = new ContactsRequest(settings); //Fetching the list of Contacts. feed = cr.GetContacts(); } catch (Exception Ex) { _exception = Ex; } finally { //Can now signal other threads to continue accessing/refreshing services. _autoEvent.Set(); } return(feed); }
public OAuthTest() { Debug.WriteLine("Calling: AuthGoogleDataInterface()"); bool init = AuthGoogleDataInterface(); if (init) { GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "My App User Agent", this.param); //requestFactory.CustomHeaders.Add(string.Format("Authorization: Bearer {0}", credential.Token.AccessToken)); var service = new SpreadsheetsService("MyService"); service.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); // Iterate through all of the spreadsheets returned foreach (SpreadsheetEntry entry in feed.Entries) { // Print the title of this spreadsheet to the screen Debug.WriteLine(entry.Title.Text); } } Debug.WriteLine(m_Init); }
/// <summary> /// Fetches list of documents in Google Drive. /// </summary> /// <returns></returns> public static DocumentsFeed GetGDriveDocList() { //Waiting for the service authentication to complete. _autoEvent.WaitOne(); DocumentsFeed documents = null; try { //In case an error was encountered go back. if (_parameters == null || _exception != null) { return(documents); } //Creating the request factory for the Drive service. GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, APPLICATION_NAME, _parameters); //Creating a service instance. DocumentsService service = new DocumentsService(APPLICATION_NAME); //Assigning the factory instance to the service. service.RequestFactory = requestFactory; DocumentsListQuery query = new DocumentsListQuery(); //Sending a query to the service to fetch list of all documents on the drive. documents = service.Query(query); } catch (Exception Ex) { _exception = Ex; } finally { //Can now signal other threads to continue accessing/refreshing services. _autoEvent.Set(); } return(documents); }
/// <summary> /// Initilize sheets API with saved token /// </summary> public void Initilize() { PermissiveCert.Instate(); RefreshToken = EditorPrefs.GetString("Datablocks_RefreshToken"); AccessToken = EditorPrefs.GetString("Datablocks_AccessToken"); Service = new SpreadsheetsService("Datablocks for Unity"); // OAuth2Parameters holds all the parameters related to OAuth 2.0. oAuthParameters = new OAuth2Parameters(); // Set your OAuth 2.0 Client Id (which you can register at oAuthParameters.ClientId = CLIENT_ID; // Set your OAuth 2.0 Client Secret, which can be obtained at oAuthParameters.ClientSecret = CLIENT_SECRET; // Set your Redirect URI, which can be registered at oAuthParameters.RedirectUri = REDIRECT_URI; // Set the scope for this particular service. oAuthParameters.Scope = SCOPE; if (!string.IsNullOrEmpty(RefreshToken)) { oAuthParameters.RefreshToken = RefreshToken; oAuthParameters.AccessToken = AccessToken; var requestFactory = new GOAuth2RequestFactory(null, "Datablocks for Unity", oAuthParameters); Service.RequestFactory = requestFactory; } }
static void Auth() { GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; }
// GET: /Configuration/ //[Authorize(Roles = "Admin, SuperUser")] public ActionResult Index(GoogleAPIAccess model) { ViewBag.Message = "Add / Update / Remove Google documents"; if (model.AccessCode != null) //after authorization { //////////////////////////////////////////////////////////////////////////// // STEP 5: Make an OAuth authorized request to Google //////////////////////////////////////////////////////////////////////////// // Initialize the variables needed to make the request GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "TaskTimer", model); SpreadsheetsService service = new SpreadsheetsService("TaskTimer"); service.RequestFactory = requestFactory; // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); //GoogleDocuments = new GoogleDocumentModel(); //GoogleDocuments.GoogleAPIAccess = model; GoogleDocuments.Documents = feed.Entries; } return(View(GoogleDocuments)); }
private void GetAuthorization() { // Get the client ID and secret from environment variables for security. var clientId = GetSecretVariable("NINODRIVE_ID"); var clientSecret = GetSecretVariable("NINODRIVE_SECRET"); if (string.IsNullOrEmpty(clientId) || string.IsNullOrEmpty(clientSecret)) { Console.WriteLine("ERROR Set NINODRIVE_ID and NINODRIVE_SECRET env vars"); Environment.Exit(-1); } // Prepare the OAuth params. oauthParams = new OAuth2Parameters(); oauthParams.ClientId = clientId + ClientId; oauthParams.ClientSecret = clientSecret; oauthParams.RedirectUri = RedirectUri; oauthParams.Scope = Scope; // Since it's a factory it's safe to continue update OAuthParams. requestFactory = new GOAuth2RequestFactory(null, ProgramName, oauthParams); // Try to get the previous token, otherwise request access code. if (!ReadTokenFromFile()) { AskAccessCode(); } }
public ActionResult Contact() { ViewBag.Message = "Your contact page."; // Get the tokens from the FileDataStore var token = new FileDataStore("Google.Apis.Auth") .GetAsync <TokenResponse>("user"); //UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync( // new ClientSecrets // { // ClientId = "68942521982-f9h411ncn58sg54s75jctuckes2ibevo.apps.googleusercontent.com", // ClientSecret = "9wyNRGLHjm_Iv_8oUtz0Eojk", // }, // new[] { CalendarService.Scope.Calendar, "https://www.google.com/m8/feeds/" }, // This will ask the client for concent on calendar and contatcs // "user", // CancellationToken.None).Result; //// Create the calendar service. //CalendarService cal_service = new CalendarService(new BaseClientService.Initializer() //{ // HttpClientInitializer = credential, // ApplicationName = "EventManagement", //}); // How do I use the found credential to create a ContactsService???? ContactsService service = new ContactsService("EventManagement"); OAuth2Parameters parameters = new OAuth2Parameters() { ClientId = "68942521982-f9h411ncn58sg54s75jctuckes2ibevo.apps.googleusercontent.com", ClientSecret = "9wyNRGLHjm_Iv_8oUtz0Eojk", RedirectUri = "https://localhost:44300/signin-google", Scope = "https://docs.google.com/feeds/ ", State = "documents", AccessType = "offline" }; parameters.AccessCode = Request.QueryString["code"]; // it gets accesstoken from google Google.GData.Client.OAuthUtil.GetAccessToken(parameters); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "EventManagement", parameters); service.RequestFactory = requestFactory; //OAuth2Parameters parameters = new OAuth2Parameters //{ // ClientId = "68942521982-f9h411ncn58sg54s75jctuckes2ibevo.apps.googleusercontent.com", // ClientSecret = "9wyNRGLHjm_Iv_8oUtz0Eojk", // // Note: AccessToken is valid only for 60 minutes // // AccessToken = token.Result.AccessToken, // // RefreshToken = token.Result.RefreshToken //}; RequestSettings settings = new RequestSettings("EventManagement", parameters); ContactsRequest cr = new ContactsRequest(settings); GContactData gdata = new GContactData(); gdata.PrintDateMinQueryResults(cr); return(View()); }
public SpreadSheetManager(OAuth2Parameters parameters) { GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", parameters); service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; }
public static AppsService CreateAppsService(string domain, OAuth2Parameters parameters) { GOAuth2RequestFactory factory = new GOAuth2RequestFactory("apps", FrameworkConfiguration.Current.WebApplication.Integration.Google.ApplicationName, parameters); AppsService service = new AppsService(domain, parameters.AccessToken); service.SetRequestFactory(factory); return(service); }
private static SpreadsheetsService CreateService(OAuth2Parameters parameters) { var requestFactory = new GOAuth2RequestFactory("structuredcontent", "", parameters); return(new SpreadsheetsService("") { RequestFactory = requestFactory }); }
public SpreadsheetsService GetService() { GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", GetParameters()); SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; return(service); }
static SpreadsheetFeed GetSpreadsheetFeed() { GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); _spreadsheetService = new SpreadsheetsService("SpreadSheet"); _spreadsheetService.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); return(_spreadsheetService.Query(query)); }
private void googleDriveToolStripMenuItem_Click(object sender, EventArgs e) { if (_Gmail == null || _Gpass == null) { ToErrorLog("Отсутствие данных", "Авторизация Google", "Ключ не содержал данных!"); return; } parameters.ClientId = CLIENT_ID; parameters.ClientSecret = CLIENT_SECRET; parameters.RedirectUri = REDIRECT_URI; //////////////////////////////////////////////////////////////////////////// // STEP 3: Get the Authorization URL //////////////////////////////////////////////////////////////////////////// // Set the scope for this particular service. parameters.Scope = SCOPE; // Get the authorization url. The user of your application must visit // this url in order to authorize with Google. If you are building a // browser-based application, you can redirect the user to the authorization // url. string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters); //System.Diagnostics.Process.Start(authorizationUrl); Authentication auth = new Authentication(); auth.URL = authorizationUrl; auth.Gpass = _Gpass; auth.Gmail = _Gmail; auth.ShowDialog(); if (auth.Key != null) { parameters.AccessCode = auth.Key; OAuthUtil.GetAccessToken(parameters); string accessToken = parameters.AccessToken; GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", parameters); service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; GooglePicture.Image = Properties.Resources.googleDrive as Bitmap; GoogleToolTip.SetToolTip(this.GooglePicture, "Доступ к Google Disk\nразрешен."); } else { MessageBox.Show("Вход не выполнен", "Google Service Access", MessageBoxButtons.OK, MessageBoxIcon.Error); } ToLog("Авторизация Google", string.Format(auth.Info)); auth.Close(); }
private IEnumerable <SpreadsheetEntry> GetSpreadsheetsImpl(GoogleAuthDTO authDTO) { GOAuth2RequestFactory requestFactory = _googleIntegration.CreateRequestFactory(authDTO); SpreadsheetsService service = new SpreadsheetsService("fr8"); service.RequestFactory = requestFactory; // Instantiate a SpreadsheetQuery object to retrieve spreadsheets. SpreadsheetQuery query = new SpreadsheetQuery(); // Make a request to the API and get all spreadsheets. SpreadsheetFeed feed = service.Query(query); return(feed.Entries.Cast <SpreadsheetEntry>()); }
public ActionResult Document(int?rowNumber, string docName, string workName) { var model = ConfigurationController.GoogleDocuments; if (model != null && model.GoogleAPIAccess != null) { GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", model.GoogleAPIAccess); SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; model.RowActive = rowNumber; if (rowNumber != null) { //add row to save table model.RowActiveSave = (ListEntry)service.Insert(model.TableSave, (ListEntry)model.Table[(int)rowNumber]); model.RowActiveSave.Elements.Add(new ListEntry.Custom() { LocalName = "workdate", Value = DateTime.Now.ToString() }); model.RowActiveSave.Elements.Add(new ListEntry.Custom() { LocalName = "hours", Value = "0" }); model.RowActiveSave.Update(); } else { GetSaveTable(); ListEntry lastRow = (ListEntry)model.TableSave.Entries.Last(); var lastRowCells = (ListEntry.CustomElementCollection)lastRow.Elements; DateTime startDate = DateTime.Now; foreach (ListEntry.Custom cell in lastRowCells) { if (cell.LocalName.Equals("workdate")) { startDate = DateTime.Parse(cell.Value); } if (cell.LocalName.Equals("hours")) { cell.Value = ((double)(DateTime.Now - startDate).Seconds / 60.0 / 60.0).ToString(); } } lastRow.Update(); } //timer.Interval = 10000; //10 sec //timer.Elapsed += timer_Elapsed; //timer.Start(); } return(RedirectToAction("Document", new { docName = docName, workName = workName })); }
public DatabaseClient(string username, string password) { GOAuth2RequestFactory requestFactory = GDataDBRequestFactory.RefreshAuthenticate(); var docService = new DocumentsService("database"); docService.RequestFactory = requestFactory; documentService = docService; var ssService = new SpreadsheetsService("database"); ssService.RequestFactory = requestFactory; spreadsheetService = ssService; }
private void GetLocalizationList() { if (string.IsNullOrEmpty(settings.spreadSheetKey)) { Debug.LogError("spreadSheetKey can not be null!"); return; } PlayerPrefs.SetString(PREF_SHEET_KEY, settings.spreadSheetKey); PlayerPrefs.Save(); if (IsTokkenEmpty) { EditorUtility.ClearProgressBar(); GetAccessCode(); return; } progressMessage = "Authenticating..."; GOAuth2RequestFactory requestFactory = RefreshAuthenticate(); SpreadsheetsService service = new SpreadsheetsService(appName); service.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); query.Uri = new System.Uri(urlRoot + settings.spreadSheetKey); progressMessage = "Get list of spreadsheets..."; spreadsheetFeed = service.Query(query); if ((spreadsheetFeed == null) || (spreadsheetFeed.Entries.Count <= 0)) { Debug.LogError("Not found any data!"); EditorUtility.ClearProgressBar(); return; } AtomEntry mySpreadSheet = spreadsheetFeed.Entries[0]; AtomLink link = mySpreadSheet.Links.FindService(GDataSpreadsheetsNameTable.WorksheetRel, null); WorksheetQuery sheetsQuery = new WorksheetQuery(link.HRef.ToString()); WorksheetFeed sheetsFeed = service.Query(sheetsQuery); foreach (WorksheetEntry sheet in sheetsFeed.Entries) { wantedSheetNames.Add(sheet.Title.Text); } localizationCount = wantedSheetNames.Count; }
public SpreadSheetWrapper() { _parameters.ClientId = "471934575594.apps.googleusercontent.com"; _parameters.ClientSecret = "Gr_MKJfuzKLYqnHCyl4m6aSP"; _parameters.RedirectUri = "urn:ietf:wg:oauth:2.0:oob"; /* 本来はGoogleDocs(Drive API)へのアクセス権限はいらないはず * スプレッドシートの作成は出来ると権限要求の説明には書いてある。 * * しかし、出来ない。Drive APIで作れとドキュメントにある。うそつき。 */ // parameters.Scope = "https://spreadsheets.google.com/feeds"; _parameters.Scope = "https://spreadsheets.google.com/feeds https://www.googleapis.com/auth/drive.file"; _requestFactory = new GOAuth2RequestFactory(null, _app_name, _parameters); }
static void Main(string[] args) { string CLIENT_ID = "YOUR_CLIENT_ID"; string CLIENT_SECRET = "YOUR_CLIENT_SECRET"; string SCOPE = "https://spreadsheets.google.com/feeds https://docs.google.com/feeds"; string REDIRECT_URI = "urn:ietf:wg:oauth:2.0:oob"; OAuth2Parameters parameters = new OAuth2Parameters(); parameters.ClientId = CLIENT_ID; parameters.ClientSecret = CLIENT_SECRET; parameters.RedirectUri = REDIRECT_URI; parameters.Scope = SCOPE; string authorizationUrl = OAuthUtil.CreateOAuth2AuthorizationUrl(parameters); MessageBox.Show(authorizationUrl); Console.WriteLine("Please visit the URL in the message box to authorize your OAuth " + "request token. Once that is complete, type in your access code to " + "continue..."); parameters.AccessCode = Console.ReadLine(); OAuthUtil.GetAccessToken(parameters); string accessToken = parameters.AccessToken; Console.WriteLine("OAuth Access Token: " + accessToken); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", parameters); SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); SpreadsheetFeed feed = service.Query(query); // Iterate through all of the spreadsheets returned foreach (SpreadsheetEntry entry in feed.Entries) { // Print the title of this spreadsheet to the screen Console.WriteLine(entry.Title.Text); } Console.ReadLine(); }
public DatabaseClient(GoogleDataSettings settings) { GOAuth2RequestFactory requestFactory = GDataDBRequestFactory.RefreshAuthenticate(settings); var docService = new DocumentsService("database") { RequestFactory = requestFactory }; documentService = docService; var ssService = new SpreadsheetsService("database") { RequestFactory = requestFactory }; spreadsheetService = ssService; }
private void GetDataTable() { var model = ConfigurationController.GoogleDocuments; //get table data // Define the URL to request the list feed of the worksheet. AtomLink listFeedLink = model.Worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); // Fetch the list feed of the worksheet. // Initialize the variables needed to make the request GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", model.GoogleAPIAccess); SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString()); model.Table = service.Query(listQuery).Entries; }
private void GetSaveTable() { var model = ConfigurationController.GoogleDocuments; //get save table WorksheetEntry worksheet = (WorksheetEntry)model.Worksheets.SingleOrDefault(w => w.Title.Text.Equals("Auto HOURS")); // Define the URL to request the list feed of the worksheet. AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); // Fetch the list feed of the worksheet. // Initialize the variables needed to make the request GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "MySpreadsheetIntegration-v1", model.GoogleAPIAccess); SpreadsheetsService service = new SpreadsheetsService("MySpreadsheetIntegration-v1"); service.RequestFactory = requestFactory; ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString()); model.TableSave = service.Query(listQuery); }
private static SpreadsheetsService GetService(GoogleParams p) { OAuth2Parameters parameters = new OAuth2Parameters(); parameters.ClientId = p.clientId; parameters.ClientSecret = p.clientSecret; parameters.RedirectUri = p.redirectUri; parameters.Scope = p.scope; parameters.RefreshToken = p.refreshToken; OAuthUtil.RefreshAccessToken(parameters); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, "DocReader", parameters); SpreadsheetsService service = new SpreadsheetsService("DocReader"); service.RequestFactory = requestFactory; return(service); }
private void ReadGSFile() { SpreadsheetsService service = new SpreadsheetsService(Constants.googleSheetsAppName); GOAuth2RequestFactory requestFactory = new GOAuth2RequestFactory(null, Constants.googleSheetsAppName, parameters); service.RequestFactory = requestFactory; SpreadsheetQuery query = new SpreadsheetQuery(); SpreadsheetFeed feed = service.Query(query); SpreadsheetEntry spreadsheet = (SpreadsheetEntry)feed.Entries[0]; WorksheetFeed wsFeed = spreadsheet.Worksheets; WorksheetEntry worksheet = (WorksheetEntry)wsFeed.Entries[0]; AtomLink listFeedLink = worksheet.Links.FindService(GDataSpreadsheetsNameTable.ListRel, null); ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString()); listFeed = service.Query(listQuery); }