Skip to content

Commit

Permalink
Merge pull request #8 from firebase/admin-sdk
Browse files Browse the repository at this point in the history
Update to Admin SDK
  • Loading branch information
samtstern authored Feb 7, 2017
2 parents 9192e14 + 446ade6 commit 0b8ece1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion database/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Getting Started
---------------

- Create your project on the [Firebase Console](https://console.firebase.google.com).
- Create a service account as described in [Adding Firebase to your Server](https://firebase.google.com/docs/server/setup) and download the JSON file.
- Create a service account as described in [Adding Firebase to your Server](https://firebase.google.com/docs/admin/setup) and download the JSON file.
- Copy the json file to this folder and rename it to `service-account.json`.
- Change the `DATATBASE_URL` variable in `Database.java` to be the URL of your Firebase Database.

Expand Down
2 changes: 1 addition & 1 deletion database/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'

// Firebase Java SDK
compile 'com.google.firebase:firebase-server-sdk:3.0.1'
compile 'com.google.firebase:firebase-admin:4.1.1'

// Sundial Job Scheduler
compile 'org.knowm:sundial:2.1.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.auth.FirebaseCredentials;
import com.google.firebase.database.*;
import com.google.firebase.quickstart.email.MyEmailer;
import com.google.firebase.quickstart.model.Post;
Expand All @@ -27,8 +28,8 @@
import java.io.FileNotFoundException;

/**
* Firebase Database quickstart sample for the server Java SDK.
* See: https://firebase.google.com/docs/server/setup#add_firebase_to_your_app
* Firebase Database quickstart sample for the Java Admin SDK.
* See: https://firebase.google.com/docs/admin/setup#add_firebase_to_your_app
*/
public class Database {

Expand Down Expand Up @@ -181,8 +182,9 @@ public static void main(String[] args) {
// Initialize Firebase
try {
// [START initialize]
FileInputStream serviceAccount = new FileInputStream("service-account.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setServiceAccount(new FileInputStream("service-account.json"))
.setCredential(FirebaseCredentials.fromCertificate(serviceAccount))
.setDatabaseUrl(DATABASE_URL)
.build();
FirebaseApp.initializeApp(options);
Expand Down

0 comments on commit 0b8ece1

Please sign in to comment.