server side script
TypeScript
async function verifyJWT(token) {
if (!token) throw new Error("No JWT token provided");
try {
const res = await axios.get(`${ENDPOINT}/account`, {
headers: {
"X-Appwrite-Project": PROJECT_ID,
"Authorization": `Bearer ${token}`,
},
});
return res.data;
} catch (err) {
console.error("Failed to fetch account data:", err.response?.data || err.message);
throw new Error("Invalid JWT or unable to fetch account");
}
}
TypeScript
Failed to fetch account data: {
message: 'User (role: guests) missing scope (account)',
code: 401,
type: 'general_unauthorized_scope',
version: '1.8.0'
}
Socket auth failed: Invalid JWT or unable to fetch account
~ client side is logged in ~ method of getting jwt below
TypeScript
const jwtResponse = await account.createJWT();
TL;DR
Developers are trying to get an account using a JWT but are facing a 401 error related to missing scope 'account'. The issue lies with the user role not having the necessary scope. The solution would be to update the user's role to include the 'account' scope.Recommended threads
- Function issue
Hi,idk whats wrong with my function but i made some changes to the env var and made sure they saved then i redeployed it,but then after it redeeployed it asked ...
- Function issue
Hi,idk whats wrong with my function but i made some changes to the env var and made sure they saved then i redeployed it,but then after it redeeployed it asked ...
- general_route_not_found - Auth Guide
If you’ve just added a subdomain to your project, verified your DNS records, and confirmed your SSL certificate is working, but you're still hitting a `general_...