Back

Invalid userId: Parameter must contain at most 36 chars. Valid chars are a-z, A-Z, 0-9, period, hyph

  • 0
  • React Native
Dr.Spark
20 Sep, 2024, 18:15

Bonjour j'ai la même erreur mais je n'arrive pas à la résoudre avec votre réponse pouvez vous m'aider voici mon code : import { Account, Avatars, Client, Databases, ID, Query, Storage, } from "react-native-appwrite"; export const appwriteConfig = { endpoint: 'https://cloud.appwrite.io/v1', platform: '...', projectId: '...', databaseId: '...', userCollectionId: '...', videoCollectionId: '...', storageId:'...'

} // Init your React Native SDK

const client = new Client();

client .setEndpoint(appwriteConfig.endpoint) .setProject(appwriteConfig.projectId) .setPlatform(appwriteConfig.platform);

const account = new Account(client); const storage = new Storage(client); const avatars = new Avatars(client); const databases = new Databases(client);

// Register user export async function createUser(email, password, username) { try { const newAccount = await account.create( ID.unique(), email, password, username );

TypeScript
if (!newAccount) throw Error;

const avatarUrl = avatars.getInitials(username);

await signIn(email, password);

const newUser = await databases.createDocument(
  appwriteConfig.databaseId,
  appwriteConfig.userCollectionId,
  ID.unique(),
  {
    accountId: newAccount.$id,
    email: email,
    username: username,
    avatar: avatarUrl,
  }
);

return newUser;

} catch (error) { throw new Error(error); } } export async function signIn(email, password) { try { const session = await account.createSession(email, password);

TypeScript
    return session;
} catch (error) {
  console.error("Error creating user: ", error.message, error);

    throw new Error(error)

}

}

TL;DR
Developers are facing an Invalid userId error with a specific character limit. The provided code snippet handles account creation and sign-in functionality. To fix the issue, developers need to ensure that the userId parameter contains at most 36 allowed characters (a-z, A-Z, 0-9, period, hyphen). Additionally, they should review the `account.createSession()` function for more details.
Steven
20 Sep, 2024, 18:17

look at the details for the account.createSession() function

Dr.Spark
20 Sep, 2024, 18:52

C'est à dire ? Pouvez vous me dire où est mon erreur s'il vous plaît ?

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more