I've run into an error while integrating OAuth2 logins into my app. Specifically, after a successful Google login, I'm encountering an "AppwriteException" indicating that the user is missing the "account" scope.
AppwriteException: User (role: guests) missing scope (account)
After consulting the documentation and discussions on Discord, I realized that I forgot to create a session after the Google login. The documentation suggests using the account.createSession(userId, secret) method to create the session.
https://appwrite.io/docs/products/auth/oauth2#init
const urlParams = new URLSearchParams(window.location.search);
const secret = urlParams.get('secret');
const userId = urlParams.get('userId');
await account.createSession(userId, secret);
However, I'm unsure about the appropriate timing to call this method in my Next.js app. It doesn't seem efficient to call it every time the page loads using useEffect. Any thoughts on this?
If there's already a solution to this, please provide the relevant URL
You'd do this once, immediately after Google redirects back to your app
(In fact, it will only work once - if you try again you should receive an "Invalid secret" error, I think)
did you find this fix?
I am facing similar problem.
bello
any updates ? 🙂
Recommended threads
- Auth Issue (maybe?)
Hi there, I'm relatively new to programming and am following a tutorial on youtube just to get an idea of how this all is suppossed to work. Now Im setting up t...
- Console cloud is down
As attached I can not login to console and it affected to our services that uses Appwrite <#1102936099745177700> <#564160731327758347>
- Failed sending to target <Email> with er...
Hi! I got this problem and trying to test the resend smtp server. But when I use messaging feature within the console it says. ```Failed sending to target <Ema...