Tag: google api

批量更新时,Google电子表格API C#缺少资源版本ID

我正在尝试使用电子表格api C#v2.2.0.0批量更新空单元格: foreach (var csvline in csv) { var csvlineParsed = csvline.Split(‘;’); for (uint index = 0; index < csvlineParsed.Length; index++) { var cellEntry = new CellEntry(i, index + 1, csvlineParsed[index]); cellFeed.Insert(cellEntry); var cell = new CellEntry(i, index + 1); cell.Id = new AtomId(string.Format("{0}/{1}", cellFeed.Self, "R" + i + "C" + index + 1)); cell.InputValue […]

Google Calendar API,只需知道他们的电子邮件地址即可向某人的日历添加活动

我已经下载了Google.Apis名称空间: using Google.Apis.Auth.OAuth2; using Google.Apis.Calendar.v3; using Google.Apis.Calendar.v3.Data; using Google.Apis.Services; 我花了一整天的时间在网上查看.NET示例,了解如何通过了解他们的电子邮件地址将事件添加到某人日历中。 我尝试了下面的代码,但它带来了错误,很明显它不会起作用: Public void Method(string email, string text) { UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync( new ClientSecrets { ClientId = “CLIENTID”, ClientSecret = “CLIENTSECRET”, }, new[] { CalendarService.Scope.Calendar }, “user”, CancellationToken.None).Result; // Create the service. var service = new CalendarService(new BaseClientService.Initializer() { HttpClientInitializer = credential, ApplicationName = “Calendar […]

由json私钥文件(ServiceAccount)创建的GoogleCredential – 如何设置用户模拟?

刚开始使用Google Apis。 在我的Google Cloud Platform帐户中,我为域范围委派创建了一个服务帐户。 我为此服务帐户保存了json格式的私钥文件。 在我的测试应用程序中,我正在创建一个GoogleCredential实例: var credential = GoogleCredential.FromStream(new FileStream(“privatekey.json”, FileMode.Open, FileAccess.Read)) .CreateScoped(Scopes); 如何设置我想要冒充的用户? 使用p12私钥时,我可以执行以下操作: var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(“xxx@developer.gserviceaccount.com”) //service Account id { Scopes = Scopes, User = “admin@xxx.com” //the user to be impersonated }.FromCertificate(new X509Certificate2(@”xxx.p12″, “notasecret”, X509KeyStorageFlags.Exportable))); 但是,我如何使用GoogleCredential和json privatkey文件“轻松实现”? 亲切的问候

如何在Windows应用程序C#.net中获取Google plus访问令牌

我正在准备一个Windows应用程序,因为我想使用oAuth2来访问来自google plus的信息。 但我对以下代码的要求不好。我可以在谷歌控制台中创建应用程序并获取应用程序访问的“代码”。 WebRequest request = WebRequest.Create( GoogleAuthenticationServer.Description.TokenEndpoint ); // You must use POST for the code exchange. request.Method = “POST”; // Create POST data. string postData = FormPostData(code); byte[] byteArray = Encoding.UTF8.`enter code here`GetBytes(postData); // Set up the POST request for the code exchange. request.ContentType = “application/x-www-form-urlencoded”; request.ContentLength = byteArray.Length; Stream dataStream = request.GetRequestStream(); […]

Google云端硬盘。 上传文件时刷新授权令牌

在将大文件上传到Google云端硬盘时刷新授权令牌的方法是什么? 例如:当前授权令牌的到期时间是“06:00 AM”。 文件上传始于“05:15 AM”。 因此,在“06:00 AM”,应用程序获得exception,因为授权令牌无效。 我已尝试使用以下源代码来解决此问题,但它无法正常工作。 /// /// Uploads a file with a specified path. /// /// The start folder. /// The path of destination file. /// The local file to upload. /// The uploaded file. private File GdUploadFile(File startFolder, string path, FileInfo localFile) { if (startFolder == null) { throw new ArgumentNullException(“startFolder”); […]

访问令牌Google+

我在使用新发布的Google+ API检索访问令牌时遇到了一些问题… 我一直在关注文档 ,我得到了一个代码(“4 / blablabla”)但是当我发送POST请求以获取访问令牌时,我得到一个“(400)错误请求”响应… 这是我的一段代码: // We have a request code, now we want an access token StringBuilder authLink = new StringBuilder(); authLink.Append(“https://accounts.google.com/o/oauth2/token”); authLink.AppendFormat(“?code={0}”, gplusCode); authLink.AppendFormat(“&client_id={0}”, myClientId); authLink.AppendFormat(“&client_secret={0}”, mySecret); authLink.AppendFormat(“&redirect_uri={0}”, myRedirectUri); authLink.Append(“&scope=https://www.googleapis.com/auth/plus.me”); authLink.Append(“&grant_type=authorization_code”); OAuthBase oAuth = new OAuthBase(); string normalizedUrl, normalizedRequestParameters; string oAuthSignature = oAuth.GenerateSignature(new Uri(authLink.ToString()), appKey, appSecret, code, null, HttpMethod.POST.ToString(), oAuth.GenerateTimeStamp(), oAuth.GenerateNonce(), […]

Google API用于获取文档/ SpreadSheet的内容

我想将Google文档的内容显示在我自己的页面中。 我可以通过使用获得所有文档的列表 http://code.google.com/apis/documents/docs/2.0/developers_guide_dotnet.html DocumentsService service = new DocumentsService(“exampleCo-exampleApp-1”); service.setUserCredentials(“jo@gmail.com”, “mypassword”); DocumentsListQuery query = new DocumentsListQuery(); DocumentsFeed feed = service.Query(query); foreach (DocumentEntry entry in feed.Entries) { Console.WriteLine(entry.Title.Text); } 如何在“我的页面”中显示“文档”的内容?

如何获取谷歌oauth的访问令牌?

我正在使用C#(ASP.NET)。 我想使用Google oauth访问我的应用中的用户个人资料详情。 我成功获得了授权码,但在获取访问令牌时遇到了问题。 我更喜欢Google教程 。 在教程中,我读到我必须发送请求并从谷歌获得响应。 为此,我使用System.Net.HttpWebRequest/HttpWebResponse (我是以正确的方式)。 我用这个代码…. byte[] buffer = Encoding.ASCII.GetBytes(“?code=” + code + “&client_id=xxx&client_secret=xxx&redirect_uri=xxxx&grant_type=authorization_code”); HttpWebRequest req = (HttpWebRequest)WebRequest.Create(“http://accounts.google.com”); req.Method = “POST”; req.ContentType = “application/x-www-form-urlencoded”; req.ContentLength = buffer.Length; Stream strm = req.GetRequestStream(); strm.Write(buffer, 0, buffer.Length); strm.Close(); HttpWebResponse resp = (HttpWebResponse)req.GetResponse(); Response.Write(((HttpWebResponse)resp).StatusDescription); 但是,我收到了错误: 远程服务器返回错误:(405)方法不允许。 更新:此处变量code是授权代码。

Google Api FreeBase数据使用c#转储解析

我想搜索谷歌Api免费库。 我想得到一般的数据量。 例如所有歌曲或电影。 我下载了数据转储gz文件。 我想知道什么是解析文件和获取我需要的数据的最佳解决方案。 我正在使用.net c#。

Google Calendar API – 不从Execute()返回C#

运行下面的代码永远不会从Execute函数返回。 我在个人Gmail帐户上有一个私人日历,我与developer.gserviceaccount.com帐户共享。 查看API管理器,使用/引用显示我已经使用过甚至命中过api。 任何想法都赞赏。 using System.Security.Cryptography.X509Certificates; using System.Web; using Google.Apis.Calendar.v3; using Google.Apis.Auth.OAuth2; using Google.Apis.Services; public class GoogleLoginWithServiceAccount { public string getEventList() { var GoogleOAuth2CertificatePath = HttpContext.Current.Server.MapPath(“~/xx/xx.p12”); var GoogleOAuth2EmailAddress = “xx-xxxx@developer.gserviceaccount.com”; var GoogleOAuth2PrivateKey = “notasecret”; var certificate = new X509Certificate2(GoogleOAuth2CertificatePath, GoogleOAuth2PrivateKey, X509KeyStorageFlags.Exportable); var credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(GoogleOAuth2EmailAddress) { //User = GoogleAccount, Scopes = new […]