
TypeScript
// src/lib/appwriteConfig.js
import { Client, Account, Databases } from "appwrite";
const client = new Client()
.setEndpoint(import.meta.env.VITE_APPWRITE_API_ENDPOINT)
.setProject(import.meta.env.VITE_APPWRITE_PROJECT_ID);
const account = new Account(client);
const databases = new Databases(client);
export { client, account, databases };
TypeScript
// Register.jsx
import { account } from "../lib/appwriteConfig";
import { Button } from "@mui/material";
export default function Register() {
const navigate = useNavigate();
const {
register: authRegister,
isLoading,
error,
clearError,
} = useAuthStore();
const {
register,
handleSubmit,
formState: { errors },
} = useForm({
resolver: zodResolver(schema),
defaultValues: {
role: "client",
},
});
const onSubmit = async (formData) => {
try {
clearError();
const user = await authRegister(formData);
if (user) {
navigate(`/${formData.role}/dashboard`);
}
} catch (error) {
console.error("Registration error:", error);
}
};
const handleGoogleLogin = async () => {
try {
clearError();
await account.createOAuth2Session(
"google",
`${window.location.origin}/dashboard`, // Success URL
`${window.location.origin}/login` // Failure URL
);
} catch (error) {
console.error("Google login error:", error);
}
};
useEffect(() => {
return () => clearError();
}, [clearError]);
return (
<Button onClick={handleGoogleLogin}>Contienue with Google</Button>)
{rest of the code is just a form for signing up normally}
}
TL;DR
Developers are encountering a 'User missing scope account' error in their code. The issue lies in the missing 'account' scope during authentication. To resolve, ensure that the client has the necessary scope for account operations in the Appwrite configuration.Recommended threads
- Subdomain failed verification
So I wanted to do a custom subdomain, because local storage doesn't work for me, but I've tried it a long time ago, it didn't work for me, and now I'm trying ag...
- [Node.js SDK] Bypass 2GB file limit?
Hello. Using either InputFile.fromPath or InputFile.fromBuffer throws this error: File size (2295467305) is greater than 2 GiB Bucket limit etc. is setup corre...
- Relationship null, even when relationshi...
Hi Everyone, im experiencing issues with set relation data. When im setting the document id from the related database most of them seem fine, except one table. ...
