How to read the Firebase serviceAccountCredentials.json with appengine servlet

3 views
Skip to first unread message

Alex Pinheiro via StackOverflow

unread,
Aug 15, 2016, 11:41:05 PM8/15/16
to google-appengin...@googlegroups.com

I'm trying to write to the Firebase database following this page instructions. I'm using a servlet running in Appengine and the error happens when trying to read the serviceAccountCredentials.json file.

Here is part of the code where the problem happens:

 public void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws IOException {

    FirebaseOptions options = new FirebaseOptions.Builder()
            .setDatabaseUrl("https://my-database.firebaseio.com/")
            .setServiceAccount(new FileInputStream("/src/main/webapp/WEB-INF/My File-89b47a8357ff.json"))
            .build();
    FirebaseApp.initializeApp(options);

And here is the logcat output:

java.security.AccessControlException: access denied ("java.io.FilePermission" "\src\main\webapp\WEB-INF\My File-89b47a8357ff.json" "read")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:372)
at java.security.AccessController.checkPermission(AccessController.java:559)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:429)
at java.lang.SecurityManager.checkRead(SecurityManager.java:888)
at java.io.FileInputStream.<init>(FileInputStream.java:135)
at java.io.FileInputStream.<init>(FileInputStream.java:101)
at com.example.myexample.myapplication.backend.MyServlet.doPost(MyServlet.java:81)

any help will be appreciated.



Please DO NOT REPLY directly to this email but go to StackOverflow:
http://stackoverflow.com/questions/38966298/how-to-read-the-firebase-serviceaccountcredentials-json-with-appengine-servlet
Reply all
Reply to author
Forward
0 new messages