I want to change current user password using Firebase in Flutter. Can any one help me on how to implement change password method?
As @Gunter mentioned that the feature is currently still unavailable, you can make use of the firebase REST API way of changing the password for the time being.
import 'package:http/http.dart' as http;
import 'dart:convert';
import 'dart:async';
Future changePassword(String newPassword) async {
const String API_KEY = 'YOUR_API_KEY';
final String changePasswordUrl =
'https://www.googleapis.com/identitytoolkit/v3/relyingparty/setAccountInfo?key=$API_KEY';
final String idToken = await user.getIdToken(); // where user is FirebaseUser user
final Map payload = {
'email': idToken,
'password': newPassword,
'returnSecureToken': true
};
await http.post(changePasswordUrl,
body: json.encode(payload),
headers: {'Content-Type': 'application/json'},
)
}
You can get the idToken
by using the getIdToken() method on the FirebaseUser object
You can get the firebase api key under the project setting in your console