java.security.AccessControlException:访问被拒绝



我创建了一个使用Prediction Api 1.5v的谷歌应用程序引擎项目。当我在本地平均本地主机localhost:8888上使用带有客户端id和客户端机密的谷歌o2authentication运行它时,它对我来说运行得很好。但当我实时运行时,它会显示一个错误为

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

我的o2auth代码是

GoogleClientSecrets-clientSecrets=GoogleClientSecret.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=新的FileCredentialsStore(新文件(System.getProperty("user.home")、".credential/prediction.json")、json_FACTORY)

应用程序引擎当前不支持写入文件。

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

高复制数据存储(HRD)非常容易使用,甚至更容易用于Objectify等项目(https://code.google.com/p/objectify-appengine/)。我建议你去看看。

相关内容

  • 没有找到相关文章

最新更新