Tag: google api

对“C:\ Windows \ system32 \ config \ systemprofile”路径的访问被拒绝

我正在使用Google Calendar Api和我的一个项目。 我不知道如何,但下面显示的错误是令人不安的。 AppFlowMetadata代码。 public class AppFlowMetadata : FlowMetadata { private static readonly IAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow(new GoogleAuthorizationCodeFlow.Initializer { ClientSecrets = new ClientSecrets { ClientId = “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com”, ClientSecret = “xxxxx_xxxxxxxxxxxxxxxxx” }, Scopes = new[] { CalendarService.Scope.Calendar }, DataStore = new FileDataStore(“Calendar.Api.Auth.Store”) }); public override string GetUserId(Controller controller) { var user = controller.Session[“UserID”]; if […]

NativeApplicationClient和OAuth2Authenticator未解析

我正在编写一个控制台应用程序来从BigQuery下载数据。 再一次,.NET库是模糊和混乱的。 在这个问题中 , 两名Google员工发布了一个回复,但我的机器上没有任何响应正在进行,因为他们还没有明确说明他们正在使用哪些参考。 我再次粘贴代码并详细说明: using DotNetOpenAuth.OAuth2; using Google.Apis.Authentication.OAuth2; using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; using Google.Apis.Bigquery.v2; using Google.Apis.Util; { public class Program { public static void Main(string[] args) { // Register an authenticator. var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); // Put your client id and secret here (from https://developers.google.com/console) // Use the installed app flow here. provider.ClientIdentifier = […]

错误:redirect_uri_mismatch在MVC应用程序中的Google登录

我正在尝试通过MVC C#应用程序将video上​​传到YouTube。 我正在关注此链接 每当我尝试运行该应用程序时,我都会收到来自Google的错误。 错误:redirect_uri_mismatch 请求中的重定向URI http:// localhost:52271 / authorize /与授权给OAuth客户端的URI不匹配。 访问https://console.developers.google.com/apis/credentials/oauthclient/CCC-XXX.apps.googleusercontent.com?project=XXXX以更新授权的重定向URI。 这是我的Json文件。 这是我的Google控制台应用程序: 错误: 有什么不对的吗 ? 谢谢。

使用服务帐户身份validation访问Google Calendar API

我能够使用.NET快速入门教程访问Google Calendar API,效果很好! 该教程的问题在于它使用Open Authentication or OAuth2 。 我想使用服务帐户身份validation执行相同操作。 ( https://support.google.com/googleapi/answer/6158857?hl=en ) 有人能举例说明如何使用服务帐户密钥文件访问我的日历吗? 我也试过尝试使用带有C#教程的Google Calendar API身份validation,但无法完成它。

使用Google Drive API v3移动文件

我正在尝试使用Google Drive API v3将文件从一个文件夹移动到另一个文件夹。 我在这里找到了文档。 我使用了文档页面中的.NET示例代码,并创建了一个如下所示的方法: public ActionResult MoveFile(string fileToMove, string destination) { DriveService service = new DriveService(new BaseClientService.Initializer { HttpClientInitializer = , ApplicationName = “APPNAME” }); var searchFiles = service.Files.List(); searchFiles.Corpus = FilesResource.ListRequest.CorpusEnum.User; searchFiles.Q = “name = ‘” + fileToMove + “‘”; searchFiles.Fields = “files(*)”; string fileToMoveId = searchFiles.Execute().Files[0].Id; searchFiles.Q = “name = ‘” […]

使用DotNetOpenAuth获取FetchData?

我已经实现了这里描述的这个简单代码 (vs 2010,webforms) protected void Page_Load(object sender, EventArgs e) { var openid = new OpenIdRelyingParty(); var response = openid.GetResponse(); if (response != null && response.Status == AuthenticationStatus.Authenticated) { FormsAuthentication.RedirectFromLoginPage(response.ClaimedIdentifier, false); } } Clickfunction: protected void btnGoogle_Click(object sender, ImageClickEventArgs e) { using (OpenIdRelyingParty openid = new OpenIdRelyingParty()) { var request = openid.CreateRequest(“https://www.google.com/accounts/o8/id”); request.RedirectToProvider(); } } 问题#1 […]

从用于Google API的Azure网站中的p12证书生成X509Certificate2时出现502错误

我正在使用此GoogleJsonWebToken类生成一个访问令牌,用于对Google Calendar API的json调用。 当我使用以下内容(使用我的实际服务帐户电子邮件)时,它在我的开发机器上的IIS Express中运行得非常好: string p12Path = HttpContext.Current.Server.MapPath(“~/App_Data/certificate.p12”); var auth = GoogleJsonWebToken.GetAccessToken(“uniquestring@developer.gserviceaccount.com”, p12Path, “https://www.googleapis.com/auth/calendar”); string Token = auth[“access_token”]; 为了测试这个,我只是在我的cshtml razor视图中调用@Token 。 当我将其发布到我的Azure网站时,它不起作用。 如果我保持GoogleJsonWebToken类未经修改,我会得到一个非常无益的502 – Web server received an invalid response while acting as a gateway or proxy server. 没有其他信息。 在一些谷歌搜索后 ,我发现这个SOpost是一个类似的问题。 所以我尝试了他们的解决方案我得到System.Security.Cryptography.CryptographicException: The system cannot find the file specified. 何时从我的Azure网站运行。 从我的开发机器运行时,我得到System.Net.WebException: The remote server […]

Google Drive Api – 带有entity framework的自定义IDataStore

我实现了我的自定义IDataStore以便我可以在我的数据库上存储最终用户令牌而不是默认实现,该实现保存在%AppData%中的FileSystem上 。 public class GoogleIDataStore : IDataStore { … public Task GetAsync(string key) { TaskCompletionSource tcs = new TaskCompletionSource(); var user = repository.GetUser(key.Replace(“oauth_”, “”)); var credentials = repository.GetCredentials(user.UserId); if (key.StartsWith(“oauth”) || credentials == null) { tcs.SetResult(default(T)); } else { var JsonData = Newtonsoft.Json.JsonConvert.SerializeObject(Map(credentials)); tcs.SetResult(NewtonsoftJsonSerializer.Instance.Deserialize(JsonData)); } return tcs.Task; } } 调节器 public async Task AuthorizeDrive(CancellationToken cancellationToken) […]

YouTube上传文件给我ArgumentNullException(C#)

我正在使用Google“Client Library for .NET”进行YouTube服务。 当我尝试上传video时,我的[Videos.Insert]请求中出现了错误。(System.ArgumentNullException)。 ArgumentNullException: Value cannot be null. Parameter name: baseUri 堆: в Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) в Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task task) в Microsoft.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task) в Microsoft.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() в Google.Apis.Upload.ResumableUpload`1.d__e.MoveNext() в c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\output\default\Src\GoogleApis\Apis\[Media]\Upload\ResumableUpload.cs:строка 459 我的代码: X509Certificate2 certificate = new X509Certificate2(@”test.p12″, “notasecret”, X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential.Initializer(“test@developer.gserviceaccount.com”) { Scopes = new[] { YouTubeService.Scope.YoutubeUpload, YouTubeService.Scope.Youtube, YouTubeService.Scope.YoutubeReadonly } }.FromCertificate(certificate)); […]

Google API / OAUTH / NativeApplicationClient / OAuth2Authenticator>退出?

我正在构建一个桌面应用程序,使用OATH按照此线程中的方案连接到Googles API: 适用于dotnet的Google API v3; 使用带有API密钥的日历 一切正常。 我已经构建了一个表单,显示一个WebBrowser来收集authCode。 但是我该如何实施“退出”呢? 找不到任何APIfunction。