-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Creating User fails #12
Comments
Pretty sure it worked before. Let me check |
This works just fine for me. Do you maybe have a more specific example? Maybe it's a specific email/password combination that's the issue? |
This works fine for me tho, print the email/password combination and make sure it exists |
I have still the same issue. The email and password is correct.
It seems like the user is not created fast enough 🤷♂️ |
print the stacktrace and see where it leads to |
@niklasbartsch Give us more than this. Like the mail or password, or a git repository to reproduce the issue. |
Maybe this smaler example helps: import 'package:api/helpers/extensions.dart';
import 'package:dart_firebase_admin/auth.dart';
import 'package:dart_frog/dart_frog.dart';
Future<Response> onRequest(RequestContext context) async {
final auth = context.firebaseAuth;
try {
await auth.createUser(
CreateRequest(
email: 'nklsbrtsch+testapp2@gmail.com',
password: 'Hello1234',
),
);
} catch (e) {
print('create user failed: $e');
}
return Response(body: 'Welcome to Dart Frog!');
}
The function is failing, but the user gets created. |
This too works fine for me. It'd help if you could create a git repository at this point. |
I created this sample [PROJECT_ID] and [username] has to be set manually user_api |
Could you make an example without dart_frog? I don't use that package and am not familiar with it. |
@niklasbartsch Check out Pharaoh It is a backend framework that is highly inspired by ExpressJS. it is very easy to use when coming from Express. you can try building your example with it |
You shouldn't need any special backend for the example. A simple main directly executing createUser should do. |
You can find my simplified code in the The user gets created but the functions throws the same error. As I mentioned it is looking too early for the not yet created user.
Your code in the /// Creates a new user.
///
/// See https://firebase.google.com/docs/auth/admin/manage-users#create_a_user
/// for code samples and detailed documentation.
///
/// Returns A Future fulfilled with the user
/// data corresponding to the newly created user.
Future<UserRecord> createUser(CreateRequest properties) async {
return _authRequestHandler
.createNewAccount(properties)
// Return the corresponding user record.
.then(getUser)
.onError<FirebaseAuthAdminException>((error, _) {
if (error.errorCode == AuthClientErrorCode.userNotFound) {
// Something must have happened after creating the user and then retrieving it.
throw FirebaseAuthAdminException(
AuthClientErrorCode.internalError,
'Unable to create the user record provided.',
);
}
throw error;
});
}
|
Where? So far, there are no indications that your "internalError" is pointing to the "Unable to create the user record". You haven't shared the message nor the stacktrace after-all.
I hate to say it, but your code works for me. |
That is not the answer I was hoping for 😅
|
@niklasbartsch just confirming you have email authentication enabled on your project? |
I'm currently too happy with |
Yes. 👍 |
Another quick check would be 'npm i firebase-tools', use the same service account and see if it works. If it does, then we suspect it's to do with how the request is authenticated? |
I only use |
I printed the user id from the I tried to get the user with the id in a separate function and that failed too.
There is only one created account that i can find with the To validate that I am in the correct project I printed the |
From your description, users are correctly created. Maybe try and make make new steps to reproduce the issue that do not rely on Such as maybe:
It sounds like this fails for you. So it'd be valuable to see how exactly you did this specifically |
I tried to create a user in the firebase console and through the app. I am not able to get both accounts with Any ideas why I get a wrong uid from the one user I can fetch? |
Nope, no idea. I have yet to see a case where it doesn't work for me. |
In the lack of a way to reproduce the issue, I'll have to close this. If you have any means of reproducing this reliably, please share :) |
Has anyone already used the
createUser
function?I always get a
FirebaseAuthAdminException
with the codeauth/internalerror
and the messageAn internal error has occurred.
The text was updated successfully, but these errors were encountered: