0

我已经创建了使用 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”“写”)

我的 o2auth 代码是

GoogleClientSecrets clientSecrets = GoogleClientSecrets.load(JSON_FACTORY, new 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(new File(System.getProperty("user.home"), ".credentials/prediction.json"), JSON_FACTORY);

4

1 回答 1

0

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

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

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

于 2013-09-20T00:43:03.837 回答