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 -
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,
);
}
}
Recommended threads
- 500 Server Error after migrating to 1.8....
Upgraded as per docs and ran migration. Everything went smoothly. I am able to log into the appwrite console however cant access any service i.e., auth, databas...
- Console not showing Site screenshot
Image link broken for self-hosted 1.8.0 (updated from 1.7.4), was working fine in older Console version (6.0.43, updated to 7.4.10).
- Storage usage keeps going up
I have a self-hosted instance running in production for over a year now. The deployment has seen multiple updates and migrations of Appwrite versions. What I ha...