【问题标题】:java.security.AccessControlException: access deniedjava.security.AccessControlException:访问被拒绝
【发布时间】:2013-08-02 11:57:33
【问题描述】:

我已经创建了使用 Prediction Api 1.5v 的 Google 应用程序引擎项目。当我使用带有客户端 ID 和客户端密码的 Google o2Auth 身份验证在本地平均 localhost:8888 上运行它时,它对我来说工作正常。但是当我实时运行它时它会给出一个错误

java.security.AccessControlException: 拒绝访问 ("java.io.FilePermission" "/base/data/home/apps/s~charn-project/1.369216781240579013/.credentials" "write")

我的 o2auth 代码如下

GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, 新的 InputStreamReader(Database.class.getResourceAsStream("/client_secrets.json"))); System.out.println("cl"+clientSecrets.getDetails().getClientSecret());

    if (clientSecrets.getDetails().getClientId().startsWith("Enter")
            || clientSecrets.getDetails().getClientSecret().startsWith("Enter ")) {

        System.out.println(
              "Enter Client ID and Secret from https://code.google.com/apis/console/?api=prediction "
              + "into prediction-cmdline-sample/src/main/resources/client_secrets.json");
          System.exit(1);
        }
        // set up file credential store
       FileCredentialStore credentialStore = new FileCredentialStore(
            new File(System.getProperty("user.home"), ".credentials/prediction.json"), JSON_FACTORY);
        // set up authorization code flow
       System.out.println("cre"+credentialStore);
       GoogleAuthorizationCodeFlow flow = new GoogleAuthorizationCodeFlow.Builder(
            httpTransport, JSON_FACTORY, clientSecrets,
            Collections.singleton(PredictionScopes.PREDICTION)).setCredentialStore(credentialStore)
            .build();

        // authorize
        return new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");

可能问题出在这一行

FileCredentialStore credentialStore = new FileCredentialStore( 新文件(System.getProperty("user.home"), ".credentials/prediction.json"), JSON_FACTORY);

【问题讨论】:

    标签: google-app-engine gwt prediction google-prediction


    【解决方案1】:

    应用引擎目前不支持写入文件。

    来源:https://developers.google.com/appengine/kb/java?csw=1#writefile

    高复制数据存储 (HRD) 相当容易使用,并且在 Objectify (https://code.google.com/p/objectify-appengine/) 等项目中更容易使用。我建议检查一下。

    【讨论】:

      猜你喜欢
      • 2012-05-14
      • 2011-09-04
      • 2013-10-25
      • 2013-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多