public async Task OnGetAsync([FromServices] IGoogleAuthProvider auth, string BaseURL) { Urls url = new Urls(BaseURL); if (string.IsNullOrEmpty(BaseURL) || !url.UrlAbsolute() || !url.UrlValid()) { MsgText = "Service directory not found, check you have specified the correct URL"; //move all text to config Response.Redirect(string.Format("{0}://{1}{2}", Request.Scheme, Request.Host.Host, Url.Content("~"))); return; } GoogleCredential credential = null; int attempt = 0; while (attempt < 3) { try { credential = await auth.GetCredentialAsync(); break; } catch (InvalidOperationException) { attempt++; foreach (string key in Request.Cookies.Keys) { Response.Cookies.Delete(key); } } } string spreadsheetId = await GoogleSheetsExport.CreateSpreadsheetAsync(credential); Thread t2 = new Thread(async delegate() { try { bool back = await GoogleSheetsExport.WriteToSpreadsheetAsync(spreadsheetId, credential, BaseURL, "configuration.json"); } catch (Exception ex) { _logger.LogError(ex, ex.Message); } }); t2.Start(); Response.Redirect("https://docs.google.com/spreadsheets/d/" + spreadsheetId + "/"); }
static void Main(string[] args) { GoogleSheetsExport.WriteToSpreadsheetAsync("https://blackburn.openplace.directory/o/ServiceDirectoryService/v2", "configuration.json").GetAwaiter().GetResult(); }