📅  最后修改于: 2022-03-11 14:59:09.587000             🧑  作者: Mango
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'},
)
}