Rank 1: Thread
I did
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 1: Thread
I did
Rank 1: Thread
I have both Web and Android but I'm building for Web first
Rank 1: Thread
Do I need to set up the API Key?
than add the web on the platform?
If you have than you should.
Rank 1: Thread
I did. Its already there.
Rank 1: Thread
The quickstart code doesn't show how to use API key though.
can you share the logs
Rank 1: Thread
AppwriteException: User (role: guests) missing scope (account) at Client.<anonymous> (file:///C:/Users/User/sides/ladanglink/node_modules/appwrite/dist/esm/sdk.js:655:23) at Generator.next (<anonymous>) at fulfilled (file:///C:/Users/User/sides/ladanglink/node_modules/appwrite/dist/esm/sdk.js:19:58) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) { code: 401, type: 'general_unauthorized_scope', response: { message: 'User (role: guests) missing scope (account)', code: 401, type: 'general_unauthorized_scope', version: '1.6.1' }}Rank 1: Thread
I got it to work
Rank 1: Thread
import { Client, Account, ID } from "appwrite";
const client = new Client() .setProject(import.meta.env.VITE_APPWRITE_PROJECT_ID); // Your project ID
const account = new Account(client);
const promise = account.create(ID.unique(), 'email@example.com', 'password');
promise.then(function (response) { console.log(response); // Success}, function (error) { console.log(error); // Failure});Rank 1: Thread
It seems I don't need to specify the endpoint... strange
Rank 1: Thread
oh wait... its still not working when trying to get the account
Do one thing check the session for the account
Rank 1: Thread
how do I check?
Rank 1: Thread
Yes
Rank 1: Thread
I tried. Still same error message.
Rank 1: Thread
Code that I tried
import { Client, Account } from "appwrite";
const client = new Client() .setProject('Your Project ID'); // Your project ID
const account = new Account(client);
const user_account = await account.getSession('current');
console.log(user_account); // SuccessRank 1: Thread
Of course I swap out the Project ID with the actual Project ID
Rank 1: Thread
Maybe I'm doing this wrong
Rank 1: Thread
I want to check if the user is logged in or not when the app is opened on their device
Rank 1: Thread
If the user is logged in, then they can see the dashboard
Rank 1: Thread
If not, direct them to the login/sign up page
Rank 1: Thread
I figure it should be checking if that account or session exists but not sure how to go about it