Skip to content

Instantly share code, notes, and snippets.

@hiranya911
Created November 27, 2017 03:13
Show Gist options
  • Save hiranya911/9461ea4119aaf8ad7037d578b570e1e2 to your computer and use it in GitHub Desktop.
Save hiranya911/9461ea4119aaf8ad7037d578b570e1e2 to your computer and use it in GitHub Desktop.
public static void initWithLimitedPrivileges() {
// Initialize the app with a custom auth variable, limiting the server's access
Map<String, Object> auth = new HashMap<String, Object>();
auth.put("uid", "my-service-worker");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.getApplicationDefault())
.setDatabaseUrl("https://databaseName.firebaseio.com")
.setDatabaseAuthVariableOverride(auth)
.build();
FirebaseApp.initializeApp(options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment