Tag: google calendar api

无法使用Google Calendar API加载System.Threading.Tasks程序集

解决了 ! 非常感谢Sam Leach 以下是我工作的app.config文件的示例: … 我也发现了这个来源 编辑:原始问题在线下。 我正在使用.NET 4.0 Framework,从我的研究中我知道不再需要System.Threading.Tasks程序集(因为它是自动包含的)。 我错了吗? 如果我是对的,我现在非常确定会引发错误,因为google-api-dotnet-client开发人员使用的System.Threading.Tasks版本与Visual Studio 2010使用的版本不同。 当我删除一些行时,我注意到在检查应用程序的行为时。 这些线出来了: gcal = new CalendarService(new BaseClientService.Initializer() { Authenticator = auth, ApplicationName = APP_NAME, }); 所以,我的新问题是: 有没有办法强制在VS2010中使用一个特定版本的参考组件? 感谢您帮助我,我相信它会对很多人有所帮助,因为google-calendar-api-v3的记录很糟糕。 亲切的问候,布鲁诺。 我的问题是我无法通过VisualStudio访问Google API作为服务。 我收到此错误: L’exception System.IO.FileLoadException n’a pas été gérée Message=Impossible de charger le fichier ou l’assembly ‘System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ ou […]

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 […]

谷歌日历Api在本地工作正常但不提高其在服务器上的身份validation

我在console.developers.google.com创建了一个项目以使用Google Calendar API 。 我们需要生成凭证并选择应用程序类型 对于Localhost和应用程序类型, other以下是Json工作正常。 { “installed”: { “client_id”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com”, “project_id”: “xxxxxx-00000”, “auth_uri”: “https://accounts.google.com/o/oauth2/auth”, “token_uri”: “https://accounts.google.com/o/oauth2/token”, “auth_provider_x509_cert_url”: “https://www.googleapis.com/oauth2/v1/certs”, “client_secret”: “xxxxxxxxxxxx”, “redirect_uris”: [ “urn:ietf:wg:oauth:2.0:oob”, “http://localhost” ] } } 对于应用程序类型Web Application在服务器上托管少数参数在Json具有不同的值,如下所示。 { “web”: { “client_id”: “xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com”, “project_id”: “xxxxxxxx-99999”, “auth_uri”: “https://accounts.google.com/o/oauth2/auth”, “token_uri”: “https://accounts.google.com/o/oauth2/token”, “auth_provider_x509_cert_url”: “https://www.googleapis.com/oauth2/v1/certs”, “client_secret”: “xxxxxxxxxxxxxxxxxxxxxxx”, “redirect_uris”: [ “http://demo.mydemo.com” ], “javascript_origins”: [ “http://demo.mydemo.com” ] } […]

Google Calendar API – 错误请求(400)尝试交换访问令牌代码

获得Google的授权代码以访问用户的日历后,我现在尝试将其替换为访问令牌。 根据自己的文档: 实际请求可能如下所示: POST /o/oauth2/token HTTP/1.1 Host: accounts.google.com Content-Type: application/x-www-form-urlencoded code=4/v6xr77ewYqhvHSyW6UJ1w7jKwAzu& client_id=8819981768.apps.googleusercontent.com& client_secret={client_secret}& redirect_uri=https://oauth2-login-demo.appspot.com/code& grant_type=authorization_code 我尝试访问它的方法如下(C#): string url = “https://accounts.google.com/o/oauth2/token”; WebRequest request = HttpWebRequest.Create(url); request.Method = “POST”; request.ContentType = “application/x-www-form-urlencoded”; string body = “code=&\r\n” + “client_id=&\r\n” + “client_secret=&\r\n” + “redirect_uri=http://localhost:4300\r\n” + “grant_type=authorization_code&\r\n” ; byte[] bodyBytes = Encoding.ASCII.GetBytes(body); request.ContentLength = bodyBytes.Length ; Stream bodyStream = request.GetRequestStream(); […]

如何为GoogleWebAuthorizationBroker.AuthorizeAsync设置return_uri?

我正在尝试在非MVC .NET Web应用程序中使用Google Calendar API 。 (这似乎是一个重要的区别。) 我试图在谷歌和Daimto的这个例子中使用这个例子中的代码以及来自这里的一些相关post的一些有用的提示。 我写了以下方法: public void GetUserCredential( String userName ) { String clientId = ConfigurationManager.AppSettings[ “Google.ClientId” ]; //From Google Developer console https://console.developers.google.com String clientSecret = ConfigurationManager.AppSettings[ “Google.ClientSecret” ]; //From Google Developer console https://console.developers.google.com String[] scopes = new string[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }; // here is where we Request the user to […]

Google Calendar V3 2 Legged身份validation失败

我正在尝试创建访问公司(业务)私人日历的网页,并在时隙可用时插入事件。 我仍面临身份validation问题。 API手册指出我应该使用API​​密钥和Oauth2LeggedAuthenticator,所以我做了所有这些并且被触发的请求非常好(它有一个oauth令牌等)但是响应是一个带有无效凭据的exception; 很容易说我的凭据是错误的,仍然是clientID,clientSecret和API Key是有效的; 我怀疑2leged认证者的最后两个参数,这是正确的吗? var provider = new NativeApplicationClient(GoogleAuthenticationServer.Description); provider.ClientIdentifier = ClientCredentials.ClientID; provider.ClientSecret = ClientCredentials.ClientSecret; var authenticator = new OAuth2LeggedAuthenticator(ClientCredentials.ClientID, ClientCredentials.ClientSecret, “myworkusername”, “workdomain.com”); Google.Apis.Calendar.v3.CalendarService service = new Google.Apis.Calendar.v3.CalendarService(authenticator); service.Key = ClientCredentials.ApiKey; var result = service.CalendarList.List().Fetch(); Assert.IsTrue(result.Items.Count > 0);

Google API V 3.0 .Net库和Google OAuth2如何处理刷新令牌

在我的应用程序中,我使用带有Google OAuth2的Google API V 3.0 .Net库来同步Google日历和Outlook日历。 我使用下面的代码来获取Google.Apis.Calendar.v3.CalendarService服务对象。 在身份validation期间,我存储了Json文件,并从中请求了Google.Apis.Auth.OAuth2.UserCredential对象。 private Google.Apis.Auth.OAuth2.UserCredential GetGoogleOAuthCredential() { GoogleTokenModel _TokenData = new GoogleTokenModel(); String JsonFilelocation = “jsonFileLocation; Google.Apis.Auth.OAuth2.UserCredential credential = null; using (var stream = new FileStream(JsonFilelocation, FileMode.Open, FileAccess.Read)) { Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.Folder = “Tasks.Auth.Store”; credential = Google.Apis.Auth.OAuth2.GoogleWebAuthorizationBroker.AuthorizeAsync( Google.Apis.Auth.OAuth2.GoogleClientSecrets.Load(stream).Secrets, new[] { Google.Apis.Calendar.v3.CalendarService.Scope.Calendar }, “user”, CancellationToken.None, new FileDataStore(“OGSync.Auth.Store”)).Result; } return credential; } 请求服务对象代码是: Google.Apis.Calendar.v3.CalendarService […]