
Hello, I am trying to setup a email otp auth for my react application via nestjs backend which is using appwrite-node sdk.
Here, when i am triggering createEmailToken with sessionClient its giving a empty secret whereas with adminClient it was giving a secret otp.
Also please let me know how to verify otp and also if we can access the email templates from node sdk.
Here's my code -
TypeScript
this.sessionClient = new Client()
.setEndpoint(this.configService.get<string>('APPWRITE_ENDPOINT'))
.setProject(this.configService.get<string>('APPWRITE_PROJECT_ID'))
.setSelfSigned(true);
this.sessionAccount = new Account(this.sessionClient);
async emailOtp(email: string) {
try {
const result = await this.sessionAccount.createEmailToken(
ID.unique(),
email,
);
console.log('Inside emailOtp', result);
return {
message: 'Email OTP sent',
userId: result.userId,
email: email,
};
} catch (error) {
this.logger.error('Failed to create email token:', error);
throw new HttpException(
'Failed to create email token',
HttpStatus.BAD_REQUEST,
);
}
}
TL;DR
Developers are setting up email OTP authentication for a React app using NestJS backend with appwrite-node SDK. They are encountering an issue where createEmailToken with sessionClient gives an empty secret, but with adminClient, it provides a secret OTP. Additionally, developers need assistance with verifying the OTP and accessing email templates from the Node SDK.Recommended threads
- I can't access my appwrite using my doma...
but if I use IP it is work
- Error importing data after server migrat...
Hello, I recently purchased a new web server and when trying to migrate my data from the old server to the new (both self-hosted instances of appwrite on coolif...
- Failed to connect to exc1 on deploy
Hi, i just came across this yesterday and it worked like a charm on selfhosting on my personal windows machine because im testing everything. But now, on Appwri...
