java.security.AccessControlException:访问被拒绝

时间:2013-08-02 11:57:34

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

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

java.security.AccessControlException:访问被拒绝(“java.io.FilePermission”“/ base / data / home /apps / s~charn-project / 3.629216781240579013 / .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(                 新文件(System.getProperty(“user.home”),“。credentials / prediction.json”),JSON_FACTORY);

1 个答案:

答案 0 :(得分:0)

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

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

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