The docs from Firebase suggest that the API offers the same features as the console:
It is not always convenient to have to visit the Firebase console in order to manage your Firebase users. The admin user management API provides programmatic access to those same users. It even allows you to do things the Firebase console cannot, such as retrieving a user's full data and changing a user's password, email address or phone number.
But the reference docs don't list a function to reset a user's password. Am I missing something?
The Admin SDK is a set of server libraries that lets you interact with Firebase from privileged environments to perform actions like: Read and write Realtime Database data with full admin privileges.
If the user login with a custom "email/password" you don't know anything else about that user (apart from the unique user id). If a user login with Facebook, or with Google sign in, you can get other information like the profile picture url. It is explained here: firebase.google.com/docs/auth/android/… .
To send a password reset email to user, on the Users page, hover over the user and click ... > Reset password. The user will receive an email with instructions on how to reset their password.
As the developer or the administrator of an app built on Firebase, you may need to perform various user management tasks. These include: Querying user profile information to populate dashboards or compile reports The Firebase Admin SDK provides a powerful API for performing these kinds of user management tasks from privileged environments.
In order to reset the password for a particular user, you will need access to the given project in Firebase. Step 4 - Hover over the user record, and select the context menu on the right The user will receive an email with a link to reset their password.
Access Google Cloud Platform resources like Cloud Storage buckets and Cloud Firestore databases associated with your Firebase projects. Create your own simplified admin console to do things like look up user data or change a user’s email address for authentication. To use Admin SDK, you need to add firebase-admin npm package to your project first:
If, on the other hand, you mean reset as in 'send a password reset email', then no, there doesn't seem to be a simple way of doing so via the Admin SDK. Show activity on this post. Yes, you can. To generate a password reset link, you provide the existing user's email. Then you can use any email service you like to send the actual email.
EDIT: This answer is now out of date, see Andrea's answer below for how to send a password reset link through the Firebase SDK.
It depends on which definition of 'reset' you're using.
If you mean reset as in 'change', then yes - the updateUser
function allows you to provide a new password. See the following example from the docs:
admin.auth().updateUser(uid, {
email: "[email protected]",
phoneNumber: "+11234567890",
emailVerified: true,
password: "newPassword",
displayName: "Jane Doe",
photoURL: "http://www.example.com/12345678/photo.png",
disabled: true
})
.then(function(userRecord) {
// See the UserRecord reference doc for the contents of userRecord.
console.log("Successfully updated user", userRecord.toJSON());
})
.catch(function(error) {
console.log("Error updating user:", error);
});
If, on the other hand, you mean reset as in 'send a password reset email', then no, there doesn't seem to be a simple way of doing so via the Admin SDK.
Yes, you can. To generate a password reset link, you provide the existing user's email. Then you can use any email service you like to send the actual email. Link to documentation.
// Admin SDK API to generate the password reset link.
const userEmail = '[email protected]';
admin.auth().generatePasswordResetLink(userEmail, actionCodeSettings)
.then((link) => {
// Construct password reset email template, embed the link and send
// using custom SMTP server.
return sendCustomPasswordResetEmail(email, displayName, link);
})
.catch((error) => {
// Some error occurred.
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With