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);
"Générer une nouvelle clé privée" depuis l'écran de paramétrage de la console de firebase> compte de service
// 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.Utiliser l'utilisateur comme utilisateur
};
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) => {
//Processus de communication HTTP en incluant idToken dans l'en-tête de la requête
}
}
});