FileInputStream refreshToken = new FileInputStream("path/to/refreshToken.json");
FirebaseOptions options = new FirebaseOptions.Builder()
.setCredentials(GoogleCredentials.fromStream(refreshToken))
.setDatabaseUrl("https://<DATABASE_NAME>.firebaseio.com/")
.build();
FirebaseApp.initializeApp(options);
"Generate new private key" from the setting screen of the console of firebase> service account
// idToken comes from the client app (shown above)
FirebaseToken decodedToken = FirebaseAuth.getInstance().verifyIdToken(idToken);
String uid = decodedToken.getUid();
Guide Document auth.signinwithemailandpassword
firebase.auth().signInWithEmailAndPassword(email, password).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
}).then((userCredencial: UserCredential | void) => {
// userCredencial.Use User as user
};
firebase.auth().signInWithEmailAndPassword(email, password).catch(function (error) {
// Handle Errors here.
}).then((userCredencial: UserCredential | void) => {
// https://firebase.google.com/docs/reference/js/firebase.auth.html?hl=ja#usercredential
if (userCredencial != null) {
userCredencial.user.getIdToken(true).then((idToken: string) => {
//Process of HTTP communication by including idToken in request header
}
}
});