I am in a node.js project and I am trying to use the new ImportUsers account in order to add users signing up using Facebook.
Now the error that returns the method it's: The uid must be a non-empty string with at most 128 characters.
Then I understand that the uid that I am generating is not good. Then... I am asking for a quick advice, to understand if I have to generate any 128 character uuid or you have a method to create a random uuid in firebase-admin (I can't find anything but just to confirm)
Many thanks
Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.
Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.
@xfernandez There's no built-in method for generating UIDs. You can generate them in anyway you like.
Please use Stackoverflow for usage questions such as this. Use the GitHub repos for bug reports and other questions directly related to the SDK code.
Hi Thanks @hiranya911
Yes, I know how to generate (i did) just wanted to know if exists a generation in sdk.
Then ok, oall clear, thanks
I am also facing similar error. In my cas I am passing valid string in UID but still
const uid = '5e9d49ecc652bf25ef18c461'
cons displayName='Mr. A'
admin.auth().createUser({
uid: uid,
displayName
}).then(d => {
console.log('User created', d)
}).catch(e => {
console.error('Error while creating user account', e)
})
But I am getting below error.
---------> 5e9d49ecc652bf25ef18c461
Error while creating user account FirebaseAuthError: The uid must be a non-empty string with at most 128 characters.
at FirebaseAuthError.FirebaseError [as constructor] (/Users/abc/project/alpha/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseAuthError.PrefixedFirebaseError [as constructor] (/Users/abc/project/alpha/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseAuthError (/Users/abc/project/alpha/node_modules/firebase-admin/lib/utils/error.js:147:16)
at validateCreateEditRequest (/Users/abc/project/alpha/node_modules/firebase-admin/lib/auth/auth-api-request.js:329:15)
at /Users/abc/project/alpha/node_modules/firebase-admin/lib/auth/auth-api-request.js:564:5
at /Users/abc/project/alpha/node_modules/firebase-admin/lib/auth/auth-api-request.js:1333:13
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
errorInfo: {
code: 'auth/invalid-uid',
message: 'The uid must be a non-empty string with at most 128 characters.'
},
codePrefix: 'auth'
}
Your code snippet works fine for me (had to fix one syntax error at `cons displayName):
User created UserRecord {
uid: '5e9d49ecc652bf25ef18c461',
email: undefined,
emailVerified: false,
displayName: 'Mr. A',
photoURL: undefined,
phoneNumber: undefined,
disabled: false,
metadata:
UserMetadata {
creationTime: 'Fri, 15 May 2020 18:03:24 GMT',
lastSignInTime: null,
lastRefreshTime: null },
providerData: [],
passwordHash: undefined,
passwordSalt: undefined,
tokensValidAfterTime: 'Fri, 15 May 2020 18:03:24 GMT',
tenantId: undefined }
This is not just a typo issue. I couldn't create a new user with a uid 5284266280082976586. What are the requirements for a valid uid.