
Hey 😄
I'm not able to create a User und send him a verification mail.
Always receive /v1/account/verification 401 (Unauthorized)
there is no old session, cause i get /v1/account/sessions/current 401 (Unauthorized)
too
just using the signIn as documented with account.get() results in
AppwriteException: User (role: guests) missing scope (account)

Can you provide the code you're using?

sure 1 sec

appwrite.ts
import {Client, Databases, Account, Avatars} from 'appwrite';
import {environment} from '@environment/environment';
export const client = new Client();
client
.setEndpoint('<endpoint>') // blanked but set in my Code
.setProject(environment.projectId)
.setLocale('de-DE');
export const account: Account = new Account(client);
export const databases: Databases = new Databases(client);
export const avatars: Avatars = new Avatars(client);
export { ID } from 'appwrite';
auth.service.ts
async signIn(email: string, password: string) {
try {
await account.deleteSession('current');
const session = account.createEmailPasswordSession(email, password);
session.then((response) => {
console.info('Session created', response);
}).catch((error) => {
console.error('Session creation failed', error);
})
const user = await account.get();
if (!user) {
console.error('User not found');
this.toast.error('User not found');
return;
}
} catch (err) {
console.error(err);
throw new Error;
}
}
async signUp(email: string, password: string, username: string) {
try {
const newAccount = await account.create(ID.unique(), email, password, username);
if (!newAccount) {
console.error('Account creation failed');
this.toast.error('Account creation failed');
return;
}
const avatarUrl = avatars.getInitials(username);
await this.signIn(email, password);
// Tried with verification here
// await account.createVerification('https://environment.baseUrl/verify');
const newUser = await databases.createDocument(
this.databaseId,
this.collectionId,
ID.unique(),
{
userId: newAccount.$id,
email,
username,
avatar: avatarUrl
}
);
return newUser;
} catch (err) {
console.error(err);
throw new Error;
}
}

tried the signUp without the signIn, just account.create -> account.createVerification

went through some posts and did alot try and error, now I'm a bit lost

After creating the account you need to create a new session so you will have to do the createEmailPasswordSession. Are you actually getting after account.deleteSession()
?

I can't remember if no current session exists does deleteSession throw and prevent the code from progressing

Removed the line and tried signIn

And?

/v1/account 401 (Unauthorized)

AppwriteException: User (role: guests) missing scope (account)

Does it tell you which method is throwing that?

Do you have a stack trace?

Can you try this?
async signIn(email: string, password: string) {
try {
const session = await account.createEmailPasswordSession(email, password);
const user = await account.get();
if (!user) {
console.error('User not found');
this.toast.error('User not found');
return;
}
} catch (err) {
console.error(err);
throw new Error;
}
}
Recommended threads
- Realtime stuck on pending
I'm hosting appwrite on a server where there's already nginx running and you can see how it's config looks for appwrite on attachted screenshot. I'm not getting...
- Appwrite Cors Errors after domain added
So I'm working on an app for my company and I've added in my domain name as the hostname for the project as well as for the custom domain. But I'm still getti...
- Appwrite custom domain verification fail...
So I've left enough time for the records to propagate and I've tried adding in a subdomain for the appwrite endpoint so as not to cause a clash with two CNAME r...
