Back
AppwriteException: Invalid `secret` param: Value must be a valid string and at least 1 chars and no
- 0
- Self Hosted
- Web
Using NextJs and try to create a session
The code is:
TypeScript
export async function createSessionClient(userId: string, sessionSecret: string): Promise<AppwriteClient> {
console.log("Creating session client...");
console.log("User ID:", userId);
console.log("Session Secret:", sessionSecret);
const client = new Client()
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT as string)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT as string)
//create session
const account = new Account(client);
const result = await account.createSession(userId, sessionSecret);
console.log("Session created:", result);
Error:
TypeScript
AppwriteException: Invalid `secret` param: Value must be a valid string and at least 1 chars and no longer than 256 chars
at async createSessionClient (src/lib/server/appwrite.ts:43:19)
at async getLoggedInUser (src/lib/server/appwrite.ts:129:24)
at async AuthGuard (src/hocs/AuthGuard.tsx:17:17)
41 | const account = new Account(client);
42 |
> 43 | const result = await account.createSession(userId, sessionSecret);
| ^
44 |
45 | console.log("Session created:", result);
46 | {
code: 400,
type: 'general_argument_invalid',
response: [Object]
}```
```json
"dependencies": {
"appwrite": "^17.0.0",
"next": "15.1.2",
"next-auth": "^4.24.11",
"node-appwrite": "^15.0.0",
"react": "18.3.1",
},
TL;DR
Developers are experiencing an error stating "Invalid `secret' param" when creating a session in a NextJS app using Appwrite. The error is due to the session secret being either null, too short, or too long. Make sure the secret provided is a valid string between 1 and 256 characters.Recommended threads
- Bulk API limitations in self-hosted serv...
Environment: Appwrite Selfhost SDK: node-appwrite 28.0 Calling `upsertRows` (also applies to `createRows`/`updateRows`/`deleteRows`) with more than 100 rows fa...
- Self Hosted GitHub connection not adding...
After upgrading to 1.9.6 i noticed that i cannot search for new repositories when trying to add new functions. I removed the existing github connection via Set...
- Unable to init function via cli
Hello! I have created a new self hosted instance of appwrite 1.9.6 and have connected to that insatnce with the cli 27.2.0 that was released a few hours ago. Wh...