This function fails to save the user to the DB after login:
TypeScript
export async function loginUsingGoogle() {
await account.createOAuth2Session(
OAuthProvider.Google,
"http://localhost:3000/verification",
"http://localhost:3000/sign-in"
);
const user = await account.get();
try {
await databases.getDocument("development", "users", user.$id);
} catch {
const imageUrl = avatar.getInitials(user.name);
await databases.createDocument("development", "users", user.$id, {
email: user.email,
name: user.name,
imageUrl,
});
}
}
I'm assuming the reason for that is that the page gets redirected to the external auth page. So how do I add a user to the DB after a successful login?
TL;DR
The function to save the user to the DB after OAuth login is failing due to redirection to the external auth page. To resolve this, consider updating the code flow to handle the successful login scenario after the redirection. This could involve implementing a callback function or handling the user creation logic after successful authentication.Recommended threads
- Anonymous Sessions using Node SDKs
I am attempting to use anonymous sessions with the Node SDK but I have simply no idea how to persist the session to a cookie, pass it to the session client, etc...
- Auth working for emulator but not for ph...
hey guys i'm using appwrite for expo react native it is working perfectly for emulator but does not working for physical devices can u explain any one and it is...
- Invalid Credentials to Log in
Hello team, I’m facing a login issue with appwrite this morning. I can’t login anymore. I haven’t changed or pushed anything since the last time I was able to l...