java.lang.IllegalArgumentException : no JSON input found while trying google calendar Api in java 异常

标签 java oauth-2.0 google-calendar-api google-api-java-client

我从 http://code.google.com/p/google-api-java-client/source/browse/calendar-cmdline-sample/?repo=samples 下载了 google calendar api 示例并在 eclipse 中创建了一个项目。 现在,当我尝试运行该项目时,我得到 java.lang.IllegalArgumentException: no JSON input found at this line

 FileCredentialStore credentialStore = new FileCredentialStore(
        new File(System.getProperty("user.home"), ".credentials/calendar.json"), JSON_FACTORY);

你们有人试过这个例子吗?这里有什么问题?

最佳答案

可以通过向 .credentials/calendar.json 文件提供输入来解决此错误。如果您在 calendar.json 中手动提供以下条目,它将起作用:

{
  "installed": {
    "client_id": "client_id",
    "client_secret": "client_secret"
  }
}

这似乎是 Windows 的问题,不允许对 calendar.json 文件设置可写权限。方法 setWritable(boolean,boolean) 返回 false,这也是导致此问题的原因。仍然手动提供 json 输入不是完美的解决方案,但您的应用程序可以正常工作。

关于java.lang.IllegalArgumentException : no JSON input found while trying google calendar Api in java 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12316039/

相关文章:

oauth-2.0 - oidc 中多个提供商的相同重定向 uri

android - Google Plus 单点登录服务器流程 - Google_AuthException 获取 OAuth2 访问 token 时出错,消息 : 'invalid_grant'

jquery - Google 日历 JSON 未按日期排序

java - 在 TestNG 上检索测试名称

java - 无法填充以 TreeSet 作为参数的 HashMap

java - Spring Oauth2 增强权限

google-calendar-api - 日历方法列表 Google API ruby​​ 客户端

javascript - 日历服务: Store and retrieve events using PropertiesService

java - 如何以编程方式将数据输入到显示表单但不具有数据上传功能的系统中

java - 无布局的 TransferHandler