Tag: google calendar api

Google Calendar API服务器端访问权限

我实现了一个实用程序,使用Google Calendar API和服务器端身份validation流程执行后台操作,无需用户界面。 现在,我想从私人日历中读取事件,而不使用具有离线访问权限的授权流程或将日历公开。 我正在使用此代码进行身份validation: GoogleCredential credential = new GoogleCredential.Builder() .setTransport(SchedulerCalendar.HTTP_TRANSPORT) .setJsonFactory(SchedulerCalendar.JSON_FACTORY) .setServiceAccountId(SchedulerCalendar.SERVICE_ACCOUNT_EMAIL) .setServiceAccountScopes(SchedulerCalendar.SCOPES) .setServiceAccountPrivateKeyFromP12File(new File(“key.p12”)).build(); 以下是阅读日历事件: List eventslist = calendar.events().list(calendarid); 未找到日历的响应为404。 有什么建议吗?

在Java JFrame中显示Google日历

我在java jframe中显示谷歌日历时遇到问题。 编辑:我确实看到谷歌日历,但它有蓝色背景,这使得查看事件变得困难。 这是我的代码片段 temp是谷歌用户名。 private void getGoogleCalendar(){ googlepane=new JPanel(new BorderLayout()); String s=”https://www.google.com/calendar/b/0/htmlembed?src=groupboba@gmail.com&ctz=America/New_York&gsessionid=OK”; JEditorPane tp=new JEditorPane(); try { HTMLEditorKit kit = new HTMLEditorKit(); StyleSheet styles =kit.getStyleSheet(); styles.importStyleSheet(new URL(s)); kit.setStyleSheet(styles); kit.install(tp); tp.setContentType(“text/html”); tp.setEditorKit(kit); tp.addHyperlinkListener(this); tp.setEditable(false); tp.setPage(s); tp.setBackground(Color.white); } catch (IOException e) { e.printStackTrace(); } googlepane.add(tp, BorderLayout.CENTER); return; }

在Google Calender api(V3)中指定日期的所有活动列表?

我想要做的是获取给定日期的给定谷歌日历中的所有事件。 现在,我们可以使用以下代码轻松获取事件列表 public Events getAllEvent() { Events events= null ; try { events = service.events().list(this.calendarID).execute(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return events ; } 我应该如何转换这个函数,以便它只在我指定的那一天给出事件。 我尝试了很多方法,但是在版本3中它不像在v2中那样工作。 任何建议。 请记住,我们正在谈论谷歌日历Api版本3 。

Google Calendar API和OAuth问题

我收到了错误 com.google.gdata.util.AuthenticationException: Unknown authorization header at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:600) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) ~[gdata-core-1.0.jar:na] at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) ~[gdata-core-1.0.jar:na] 尝试通过API访问Google日历数据时。 以下是该错误之前发生的事情。 1)我通过Googlevalidation: final AccessTokenResponse response = new GoogleAuthorizationCodeGrant(httpTransport, jsonFactory, clientId, clientSecret, authorizationCode, redirectUrl).execute(); final GoogleAccessProtectedResource accessProtectedResource = new GoogleAccessProtectedResource( response.accessToken, httpTransport, jsonFactory, clientId, clientSecret, response.refreshToken); LOGGER.debug(“response.accessToken: {}”, response.accessToken); this.oauthAccessToken = response.accessToken; … 2)我通过任务API读取了一些数据: this.service […]

如何在日历Api中禁用Google的“video通话”默认设置?

我正在实施一个在日历中创建活动的软件,但是当我创建它时,Google会默认添加一个video群聊(video通话)链接。 多数民众赞成使这一事件有点令人困惑。 我知道您可以通过转到用户高级选项并取消选中该选项来消除此问题,但我无法访问它。 我正在使用java和OAuth 2.0来获取具有权限的令牌,并使用calendar v3 api来创建事件。 无论如何你可以在整个代码中消除这个环聊链接吗? 在我发现的文档中: myEntry.setHangoutLink(null); 但它仍然无效。

如何使用服务帐户正确获取用户的日历事件?

我正在尝试为域中的用户检索日历事件。 我有服务帐户访问权限,但是当我尝试获取特定用户事件时,我收到404错误。 inheritance人连接代码: NetHttpTransport httpTransport = GoogleNetHttpTransport.newTrustedTransport(); GoogleCredential credential = new GoogleCredential.Builder() .setTransport(httpTransport) .setJsonFactory(JSON_FACTORY) .setServiceAccountId(googleApiServiceAccountId) .setServiceAccountScopes(Collections.singleton(CalendarScopes.CALENDAR_READONLY)) .setServiceAccountPrivateKey(SecurityUtils.loadPrivateKeyFromKeyStore( SecurityUtils.getPkcs12KeyStore(), getClass().getClassLoader().getResourceAsStream(googleApiPrivateKeyPath), NOTASECRET, PRIVATEKEY, NOTASECRET)) .build(); calendarApi = new Calendar.Builder(httpTransport, JSON_FACTORY, credential).setApplicationName(getApplicactionName()).build(); 活动列表方法: public List getCalendarEventsForUserAndDates(String userEmail, Long dateFrom, Long dateTo) { try { String pageToken = null; List allEvents = Lists.newArrayList(); do { ArrayMap parameters = new […]

尝试使用Google Calendar API v3 for Java创建全天活动会导致错误

我可以使用Java v3 Google Calendar API创建一个定时事件(根据Google网站上的示例代码),但我需要创建一个全天活动。 我调用事件的setStart()和setEnd(),即 event.setStart(startEventDateTime); event.setEnd(endEventDateTime); 这些方法需要和EventDateTime,即 EventDateTime startEventDateTime = new EventDateTime().setDateTime(startDateTime); EventDateTime endEventDateTime = new EventDateTime().setDateTime(endDateTime); 我使用setDateTime()方法,因为setDate()会导致404错误。 setDateTime()需要com.google.api.client.util.DateTime对象 DateTime startDateTime = new DateTime(startDate, TimeZone.getTimeZone(“UTC”)); DateTime endDateTime = new DateTime(endDate, TimeZone.getTimeZone(“UTC”)); 传入TimeZone会给出一个时间元素,因此它不是一整天的事件。 我已经尝试将dateOnly设置为true但这会产生错误: DateTime startDateTime = new DateTime(true, startDate.getTime(), 0); 我无法获得创建DateTime的其他方法:日期日期,TimeZone区域长值日期值长值,整数tzShift字符串值 我以哪种方式创建DateTime,我可以使用setDate(),即新的EventDateTime()。setDate(…)? 有没有人有经过测试的代码片段? 为什么Google没有记录这一点? ps有趣的是,当从Google读取事件时,使用getDate()会导致定时事件发生exception,getDateTime()会导致全天事件发生exception。 需要对全天事件使用getDate(),对定时事件使用getDateTime()。

如何使用Java访问Google Calendar REST API v3

我正在开发一个项目,我必须使用REST访问一组Google日历并使用Java。 该程序位于私人非Google服务器上,定期(通过cron作业)连接到Google帐户,获取链接到该帐户的日历列表,获取每个日历的上个月的事件,并返回包含所有日历的XML文件信息。 该程序应该能够在没有任何用户输入的情况下执行和访问日历。 目前,该项目指定只读取日历,而不是修改日历(因此只会进行GET / LIST调用)。 我查看了Google文档并使用客户端库查看了示例代码,并且在访问日历API之前,几乎所有给出的示例都需要OAuth 2.0用户同意。 甚至REST API文档页面也要求您激活OAuth 2.0以返回所请求的信息(否则返回HTTP 40X错误代码和包含错误状态和消息的JSON文件)。 我如何连接到Google Calendar REST API以获取我需要的信息,一切都是通过REST调用完成的,并且在执行时无需用户同意? 或者我是否过于复杂,只需要在Google云端控制台的Resgistered Apps部分中找到“服务器密钥”? 或者我是否要求同时使用OAuth和开发人员密钥? (我发现有人在标题下提到它:Google Calendar API v3硬编码凭据;然而,问题和解决方案是针对PHP的,我不知道Java中是否可能存在类似的东西)。 我确实看到了创建一个带有服务帐户的JWT的可能性(使用Google云控制台,注册为Web应用程序,并且它位于’证书’下),但是我没有找到如何将这个与REST调用一起使用一个Java程序。 以下链接( http://aleksz-programming.blogspot.be/2012/11/google-calendar-api.html )表示可以通过“Web服务器应用程序”或“已安装的应用程序”访问信息,但不能不详细说明。 但是,在Google OAuth 2.0文档页面上,“Web服务器应用程序”部分仍需要用户输入和同意。 这是真的吗? 我还找到了此页面( https://developers.google.com/accounts/docs/OAuth2Login ),但未能看到如何在不使用用户同意页面的情况下使用它。 我确实看到了一些“双腿OAuth”的引用。 但似乎这不是OAuth 2.0,而是版本1是做事。 这是我项目的可能解决方案吗? 如果是这样,我需要从Google Cloud Console获取哪些信息才能使其正常运行? 我希望我已经提供了足够的信息来说明我正在寻找什么,而且到目前为止还没有涵盖这个问题。 我做了研究,并没有找到足够接近我所寻找的东西。 我无法发布超过2个链接(缺乏声誉),但确实查看了Google Calendar v3 REST API,以及指定创建JWT的页面。

Google Calendar API:如何在没有Google密码的情况下创建/编辑/删除活动?

我有一个应用程序,可以在Google日历中读取/编辑/删除事件。 现在有必要输入Google用户名和密码来执行此操作。 但是,这是一个问题:许多用户害怕泄露密码。 问题:有没有办法访问Google日历中的事件而无需询问用户他/她的Google密码(即通过OAuth)? 提前致谢 德米特里 PS:应用程序是用Java编写的。

在Google日历java上设置事件ID

我试图在Java上的google calendar v3 api上设置eventId,但它给了我400条错误“message”:“资源ID值无效。”。 有没有办法自己设置谷歌日历的事件ID? 谢谢