Web Developer
IT WOULDN'T BELEAVE I AM SIGNED IN
\nusing this","author":{"@type":"Person","name":"Objection"},"datePublished":"2025-11-24T15:50:11.814Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442542829967507458"},{"@type":"Comment","text":"Hey! firstly, please check for these in your project setup:\n1. Your project endpoint & ID are set before anything else\n2. Your OAuth redirect URL EXACTLY matches your actual site\n3. Call `account.get()` only after the OAuth redirect finishes\n4. Make sure the domain you’re testing from is added in Appwrite Platform\n5. Any important cookies are not blocked by your browser","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T15:51:11.589Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442543080682029289"},{"@type":"Comment","text":"It says you haven't defined `ID`. Can you please share where in your code you are using this variable?","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T15:52:59.514Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442543533352292362"},{"@type":"Comment","text":"signinBtn.onclick = async function() {\n const email = emailInput.value;\nconst token = await account.createMagicURLToken(\n ID.unique(),\n email,\n 'http://127.0.0.1:5501/verfy.html'\n);\n\n };","author":{"@type":"Person","name":"Objection"},"datePublished":"2025-11-24T15:53:34.616Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442543680581009679"},{"@type":"Comment","text":"so i feel that's a bit stupid question but what is OAuth redirect URL i went to google api services and maid an OAuth 2.0 Client IDs then i got the client id and secret and inputted them in the google auth in the dashboard","author":{"@type":"Person","name":"Objection"},"datePublished":"2025-11-24T15:59:03.558Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442545060263755930"},{"@type":"Comment","text":"OAuth redirect URL means where the user will be redirected to after successful authentication","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T16:02:25.551Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442545907483672587"},{"@type":"Comment","text":"Try doing `Appwrite.ID.unique()` instead of `ID.unique()`","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T16:04:35.372Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442546451992285346"},{"@type":"Comment","text":"Or even better, can you share the file where you've written this? I want to see how you are importing these pre-defined vars?","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T16:05:24.933Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442546659866447884"},{"@type":"Comment","text":"(No text)","author":{"@type":"Person","name":"Mazrouaa"},"datePublished":"2025-11-24T16:11:03.290Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442548079038566431"},{"@type":"Comment","text":"so the sign code worked and google sign in worked the problem is now with the auth verification","author":{"@type":"Person","name":"Mazrouaa"},"datePublished":"2025-11-24T16:11:48.704Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442548269518553149"},{"@type":"Comment","text":"Hey! Try using v13","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T17:55:07.944Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442574271015817256"},{"@type":"Comment","text":"See whether it works and let me know the results","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-24T17:55:25.609Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442574345108062239"},{"@type":"Comment","text":"so it didnt really solve the auth check but after some chatting with chat gpt he came up with this:\nasync function authCheck() {\n try {\n // Check if user is logged in\n const user = await account.get();\n console.log(\"User logged in:\", user);\n\n // 🔒 Check if email is verified\n if (!user.emailVerification) {\n document.getElementById('status').innerText = \"Please verify your email first.\";\n alert(\"Your email is not verified. Check your inbox!\");\n\n // Optional: allow resend\n document.getElementById('resendBtn')?.classList.remove(\"hidden\");\n return; // Stop redirecting\n }\n\n // Email verified → redirect\n window.location.href = \"/index.html\";\n\n } catch (err) {\n console.log(\"No active session:\", err);\n\n // Check for Magic Link login (only if verification done)\n const params = new URLSearchParams(window.location.search);\n const userId = params.get('userId');\n const secret = params.get('secret');\n\n if (userId && secret) {\n try {\n await account.deleteSession('current').catch(() => {});\n await account.updateMagicURLSession(userId, secret);\n\n const user = await account.get();\n if (!user.emailVerification) {\n document.getElementById('status').innerText = \"Verify your email to continue.\";\n return;\n }\n\n window.history.replaceState({}, document.title, window.location.pathname);\n window.location.href = \"/index.html\";\n\n } catch (magicErr) {\n console.error(\"Magic link login failed:\", magicErr);\n }\n }\n }\n}\n\nauthCheck();\n\ni dont really understand it but if it can help someone here it is","author":{"@type":"Person","name":"Mazrouaa"},"datePublished":"2025-11-25T13:14:58.157Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442866153524301957"},{"@type":"Comment","text":"It is for verifying the logged in user","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-25T13:18:46.400Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442867110845091902"},{"@type":"Comment","text":"I read this code and realized one thing, that in your previous code, you weren't calling this update function `updateMagicURLSession(userId, secret)` which is why your user's session was never really initiated","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-25T13:29:53.664Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442869909553025167"},{"@type":"Comment","text":"And you kept getting that error","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-25T13:30:23.230Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442870033561686131"},{"@type":"Comment","text":"But anyways, thanks for sharing it here for others. I appriciate it!","author":{"@type":"Person","name":"Devika"},"datePublished":"2025-11-25T13:30:53.057Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442870158665187399"},{"@type":"Comment","text":"Error: User is not authenticated","author":{"@type":"Person","name":"Guille"},"datePublished":"2025-11-25T14:20:51.987Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442882737089548349"},{"@type":"Comment","text":"The error: `User is not authenticated` usually means the SDK isn't detecting the cookie, are you using nextjs? or any SSR framework?","author":{"@type":"Person","name":"Guille"},"datePublished":"2025-11-25T14:22:06.127Z","url":"https://appwrite.io/threads/1442540571465089124#message-1442883048054984775"}]}}
Votes
0
Replies
21
Participants
3
Messages
22
Web Developer
IT WOULDN'T BELEAVE I AM SIGNED IN
Web Developer
google oauth by the way
Web Developer
this with magic link log in
Web Developer
using this
Hey! firstly, please check for these in your project setup:
account.get() only after the OAuth redirect finishesIt says you haven't defined ID. Can you please share where in your code you are using this variable?
Web Developer
signinBtn.onclick = async function() {
const email = emailInput.value;
const token = await account.createMagicURLToken(
ID.unique(),
email,
'http://127.0.0.1:5501/verfy.html'
);
};
Web Developer
so i feel that's a bit stupid question but what is OAuth redirect URL i went to google api services and maid an OAuth 2.0 Client IDs then i got the client id and secret and inputted them in the google auth in the dashboard
OAuth redirect URL means where the user will be redirected to after successful authentication
Try doing Appwrite.ID.unique() instead of ID.unique()
Or even better, can you share the file where you've written this? I want to see how you are importing these pre-defined vars?
Rank 1: Thread
Rank 1: Thread
so the sign code worked and google sign in worked the problem is now with the auth verification
Hey! Try using v13
See whether it works and let me know the results
Rank 1: Thread
so it didnt really solve the auth check but after some chatting with chat gpt he came up with this:
async function authCheck() {
try {
// Check if user is logged in
const user = await account.get();
console.log("User logged in:", user);
// 🔒 Check if email is verified
if (!user.emailVerification) {
document.getElementById('status').innerText = "Please verify your email first.";
alert("Your email is not verified. Check your inbox!");
// Optional: allow resend
document.getElementById('resendBtn')?.classList.remove("hidden");
return; // Stop redirecting
}
// Email verified → redirect
window.location.href = "/index.html";
} catch (err) {
console.log("No active session:", err);
// Check for Magic Link login (only if verification done)
const params = new URLSearchParams(window.location.search);
const userId = params.get('userId');
const secret = params.get('secret');
if (userId && secret) {
try {
await account.deleteSession('current').catch(() => {});
await account.updateMagicURLSession(userId, secret);
const user = await account.get();
if (!user.emailVerification) {
document.getElementById('status').innerText = "Verify your email to continue.";
return;
}
window.history.replaceState({}, document.title, window.location.pathname);
window.location.href = "/index.html";
} catch (magicErr) {
console.error("Magic link login failed:", magicErr);
}
}
}
}
authCheck();
i dont really understand it but if it can help someone here it is
It is for verifying the logged in user
I read this code and realized one thing, that in your previous code, you weren't calling this update function updateMagicURLSession(userId, secret) which is why your user's session was never really initiated
And you kept getting that error
But anyways, thanks for sharing it here for others. I appriciate it!
Error: User is not authenticated
The error: User is not authenticated usually means the SDK isn't detecting the cookie, are you using nextjs? or any SSR framework?